From 40c3d67d7e090ece79bfc8b2f4377f108a00bf21 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 May 2024 15:50:54 -0400 Subject: [PATCH] make the value configurable --- src/main/java/com/jagrosh/jmusicbot/BotConfig.java | 8 +++++++- .../java/com/jagrosh/jmusicbot/audio/PlayerManager.java | 2 +- .../audio/TransformativeAudioSourceManager.java | 2 +- src/main/resources/reference.conf | 9 +++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java index 7a66cc16d..a9d53c2a0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java +++ b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java @@ -43,7 +43,7 @@ public class BotConfig successEmoji, warningEmoji, errorEmoji, loadingEmoji, searchingEmoji, evalEngine; private boolean stayInChannel, songInGame, npImages, updatealerts, useEval, dbots; - private long owner, maxSeconds, aloneTimeUntilStop; + private long owner, maxSeconds, aloneTimeUntilStop, maxYTPlaylistPages; private double skipratio; private OnlineStatus status; private Activity game; @@ -91,6 +91,7 @@ public void load() useEval = config.getBoolean("eval"); evalEngine = config.getString("evalengine"); maxSeconds = config.getLong("maxtime"); + maxYTPlaylistPages = config.getLong("maxytplaylistpages"); aloneTimeUntilStop = config.getLong("alonetimeuntilstop"); playlistsFolder = config.getString("playlistsfolder"); aliases = config.getConfig("aliases"); @@ -341,6 +342,11 @@ public long getMaxSeconds() return maxSeconds; } + public long getMaxYTPlaylistPages() + { + return maxYTPlaylistPages; + } + public String getMaxTime() { return TimeUtil.formatTime(maxSeconds * 1000); diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java b/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java index 337381946..89d87c5cd 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java @@ -63,7 +63,7 @@ public void init() AudioSourceManagers.registerLocalSource(this); DuncteBotSources.registerAll(this, "en-US"); - source(YoutubeAudioSourceManager.class).setPlaylistPageCount(50); + source(YoutubeAudioSourceManager.class).setPlaylistPageCount((int)bot.getConfig().getMaxYTPlaylistPages()); } public Bot getBot() diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/TransformativeAudioSourceManager.java b/src/main/java/com/jagrosh/jmusicbot/audio/TransformativeAudioSourceManager.java index dc57f6476..7e4734d69 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/TransformativeAudioSourceManager.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/TransformativeAudioSourceManager.java @@ -16,10 +16,10 @@ package com.jagrosh.jmusicbot.audio; import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; -import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager; import com.sedmelluq.discord.lavaplayer.track.AudioItem; import com.sedmelluq.discord.lavaplayer.track.AudioReference; import com.typesafe.config.Config; +import dev.lavalink.youtube.YoutubeAudioSourceManager; import java.io.IOException; import java.util.Collections; import java.util.List; diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 741b7a86c..a4fda1e02 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -98,6 +98,15 @@ stayinchannel = false maxtime = 0 +// This sets the maximum number of pages of songs that can be loaded from a YouTube +// playlist. Each page can contain up to 100 tracks. Playing a playlist with more +// pages than the maximum will stop loading after the provided number of pages. +// For example, if the max was set to 15 and a playlist contained 1850 tracks, +// only the first 1500 tracks (15 pages) would be loaded. By default, this is +// set to 10 pages (1000 tracks). + +maxytplaylistpages = 10 + // This sets the ratio of users that must vote to skip the currently playing song. // Guild owners can define their own skip ratios, but this will be used if a guild