Search in sources :

Example 1 with YoutubeAudioSourceManager

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();
    }
}
Also used : FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) Color(java.awt.Color) Utils(net.kodehawa.mantarobot.utils.Utils) IntConsumer(java.util.function.IntConsumer) DiscordUtils(net.kodehawa.mantarobot.utils.DiscordUtils) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) ReactionOperations(net.kodehawa.mantarobot.core.listeners.operations.ReactionOperations) AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Permission(net.dv8tion.jda.core.Permission) DBGuild(net.kodehawa.mantarobot.data.entities.DBGuild) YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager) GuildData(net.kodehawa.mantarobot.data.entities.helpers.GuildData) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) MantaroData(net.kodehawa.mantarobot.data.MantaroData) Optional(java.util.Optional) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) GuildData(net.kodehawa.mantarobot.data.entities.helpers.GuildData) DBGuild(net.kodehawa.mantarobot.data.entities.DBGuild) YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)

Example 2 with YoutubeAudioSourceManager

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;
}
Also used : YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager) Scope(org.springframework.context.annotation.Scope) Bean(org.springframework.context.annotation.Bean)

Example 3 with 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;
}
Also used : YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager)

Example 4 with YoutubeAudioSourceManager

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;
}
Also used : YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager)

Example 5 with YoutubeAudioSourceManager

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;
}
Also used : YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager)

Aggregations

YoutubeAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager)8 BandcampAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.bandcamp.BandcampAudioSourceManager)2 BeamAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.beam.BeamAudioSourceManager)2 HttpAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.http.HttpAudioSourceManager)2 SoundCloudAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.soundcloud.SoundCloudAudioSourceManager)2 TwitchStreamAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.twitch.TwitchStreamAudioSourceManager)2 VimeoAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.vimeo.VimeoAudioSourceManager)2 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)1 DefaultAudioPlayerManager (com.sedmelluq.discord.lavaplayer.player.DefaultAudioPlayerManager)1 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)1 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)1 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)1 Color (java.awt.Color)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 IntConsumer (java.util.function.IntConsumer)1 Slf4j (lombok.extern.slf4j.Slf4j)1 ClypitAudioSourceManager (ml.duncte123.skybot.objects.audiomanagers.clypit.ClypitAudioSourceManager)1 SpotifyAudioSourceManager (ml.duncte123.skybot.objects.audiomanagers.spotify.SpotifyAudioSourceManager)1