Skip to content

Commit 6a5a9c7

Browse files
authored
Change playlist page count (#1542)
* change playlist page count * make the value configurable * small refactor
1 parent 8557f7a commit 6a5a9c7

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

src/main/java/com/jagrosh/jmusicbot/BotConfig.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class BotConfig
4444
evalEngine;
4545
private boolean stayInChannel, songInGame, npImages, updatealerts, useEval, dbots;
4646
private long owner, maxSeconds, aloneTimeUntilStop;
47+
private int maxYTPlaylistPages;
4748
private double skipratio;
4849
private OnlineStatus status;
4950
private Activity game;
@@ -91,6 +92,7 @@ public void load()
9192
useEval = config.getBoolean("eval");
9293
evalEngine = config.getString("evalengine");
9394
maxSeconds = config.getLong("maxtime");
95+
maxYTPlaylistPages = config.getInt("maxytplaylistpages");
9496
aloneTimeUntilStop = config.getLong("alonetimeuntilstop");
9597
playlistsFolder = config.getString("playlistsfolder");
9698
aliases = config.getConfig("aliases");
@@ -341,6 +343,11 @@ public long getMaxSeconds()
341343
return maxSeconds;
342344
}
343345

346+
public int getMaxYTPlaylistPages()
347+
{
348+
return maxYTPlaylistPages;
349+
}
350+
344351
public String getMaxTime()
345352
{
346353
return TimeUtil.formatTime(maxSeconds * 1000);

src/main/java/com/jagrosh/jmusicbot/audio/PlayerManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public void init()
4949
{
5050
TransformativeAudioSourceManager.createTransforms(bot.getConfig().getTransforms()).forEach(t -> registerSourceManager(t));
5151

52-
registerSourceManager(new YoutubeAudioSourceManager(true));
52+
YoutubeAudioSourceManager yt = new YoutubeAudioSourceManager(true);
53+
yt.setPlaylistPageCount(bot.getConfig().getMaxYTPlaylistPages());
54+
registerSourceManager(yt);
5355

5456
registerSourceManager(SoundCloudAudioSourceManager.createDefault());
5557
registerSourceManager(new BandcampAudioSourceManager());
@@ -63,8 +65,6 @@ public void init()
6365
AudioSourceManagers.registerLocalSource(this);
6466

6567
DuncteBotSources.registerAll(this, "en-US");
66-
67-
source(YoutubeAudioSourceManager.class).setPlaylistPageCount(10);
6868
}
6969

7070
public Bot getBot()

src/main/java/com/jagrosh/jmusicbot/audio/TransformativeAudioSourceManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
package com.jagrosh.jmusicbot.audio;
1717

1818
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
19-
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
2019
import com.sedmelluq.discord.lavaplayer.track.AudioItem;
2120
import com.sedmelluq.discord.lavaplayer.track.AudioReference;
2221
import com.typesafe.config.Config;
22+
import dev.lavalink.youtube.YoutubeAudioSourceManager;
2323
import java.io.IOException;
2424
import java.util.Collections;
2525
import java.util.List;

src/main/resources/reference.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ stayinchannel = false
9898

9999
maxtime = 0
100100

101+
// This sets the maximum number of pages of songs that can be loaded from a YouTube
102+
// playlist. Each page can contain up to 100 tracks. Playing a playlist with more
103+
// pages than the maximum will stop loading after the provided number of pages.
104+
// For example, if the max was set to 15 and a playlist contained 1850 tracks,
105+
// only the first 1500 tracks (15 pages) would be loaded. By default, this is
106+
// set to 10 pages (1000 tracks).
107+
108+
maxytplaylistpages = 10
109+
101110

102111
// This sets the ratio of users that must vote to skip the currently playing song.
103112
// Guild owners can define their own skip ratios, but this will be used if a guild

0 commit comments

Comments
 (0)