use of com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager in project MantaroBot by Mantaro.
the class AudioRequester method loadSingle.
private void loadSingle(AudioTrack audioTrack, boolean silent) {
AudioTrackInfo trackInfo = audioTrack.getInfo();
DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
GuildData guildData = dbGuild.getData();
String title = trackInfo.title;
long length = trackInfo.length;
long queueLimit = !Optional.ofNullable(dbGuild.getData().getMusicQueueSizeLimit()).isPresent() ? MAX_QUEUE_LENGTH : dbGuild.getData().getMusicQueueSizeLimit();
int fqSize = guildData.getMaxFairQueue();
if (getMusicManager().getTrackScheduler().getQueue().size() > queueLimit && !MantaroData.db().getUser(event.getMember()).isPremium() && !dbGuild.isPremium()) {
if (!silent)
event.getChannel().sendMessage(String.format(":warning: Could not queue %s: Surpassed queue song limit!", title)).queue(message -> message.delete().queueAfter(30, TimeUnit.SECONDS));
if (musicManager.getTrackScheduler().isStopped())
event.getGuild().getAudioManager().closeAudioConnection();
return;
}
if (audioTrack.getInfo().length > MAX_SONG_LENGTH && !MantaroData.db().getUser(event.getMember()).isPremium() && !dbGuild.isPremium()) {
event.getChannel().sendMessage(String.format(":warning: Could not queue %s: Track is longer than 21 minutes! (%s)", title, AudioUtils.getLength(length))).queue();
if (musicManager.getTrackScheduler().isStopped())
//do you?
event.getGuild().getAudioManager().closeAudioConnection();
return;
}
//Comparing if the URLs are the same to be 100% sure they're just not spamming the same url over and over again.
if (musicManager.getTrackScheduler().getQueue().stream().filter(track -> track.getInfo().uri.equals(audioTrack.getInfo().uri)).count() > fqSize) {
event.getChannel().sendMessage(EmoteReference.ERROR + String.format("**Surpassed fair queue level of %d (Too many songs which are exactly equal)**", fqSize + 1)).queue();
return;
}
musicManager.getTrackScheduler().queue(new AudioTrackContext(event.getAuthor(), event.getChannel(), audioTrack.getSourceManager() instanceof YoutubeAudioSourceManager ? "https://www.youtube.com/watch?v=" + audioTrack.getIdentifier() : trackUrl, audioTrack));
if (!silent) {
event.getChannel().sendMessage(String.format("📣 Added to queue -> **%s** **!(%s)**", title, AudioUtils.getLength(length))).queue();
}
}
use of com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager in project FredBoat by Frederikam.
the class AudioPlayerManagerConfiguration method youtubeAudioSourceManager.
@Bean(destroyMethod = "")
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public YoutubeAudioSourceManager youtubeAudioSourceManager() {
YoutubeAudioSourceManager youtubeAudioSourceManager = new YoutubeAudioSourceManager();
youtubeAudioSourceManager.configureRequests(config -> RequestConfig.copy(config).setCookieSpec(CookieSpecs.IGNORE_COOKIES).build());
youtubeAudioSourceManager.setMixLoaderMaximumPoolSize(50);
return youtubeAudioSourceManager;
}
use of com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager in project FlareBot by FlareBot.
the class SavedPlaylistExtractor method newSourceManagerInstance.
@Override
public AudioSourceManager newSourceManagerInstance() throws Exception {
YoutubeAudioSourceManager manager = new YoutubeAudioSourceManager();
manager.setPlaylistPageCount(100);
return manager;
}
use of com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager in project FlareBot by FlareBot.
the class YouTubeExtractor method newSourceManagerInstance.
@Override
public AudioSourceManager newSourceManagerInstance() throws Exception {
YoutubeAudioSourceManager manager = new YoutubeAudioSourceManager();
manager.setPlaylistPageCount(100);
return manager;
}
use of com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager in project FlareBot by FlareBot.
the class YouTubeSearchExtractor method newSourceManagerInstance.
@Override
public AudioSourceManager newSourceManagerInstance() throws Exception {
YoutubeAudioSourceManager manager = new YoutubeAudioSourceManager();
manager.setPlaylistPageCount(100);
return manager;
}
Aggregations