Skip to content

Commit cd34ee1

Browse files
authored
Merge pull request #254 from ByteAlex/dev
Added retryLimit configuration
2 parents 24680c5 + 2a62bc3 commit cd34ee1

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

LavalinkServer/application.yml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ lavalink:
2323
#excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
2424
#strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
2525
#searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
26+
#retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times
2627

2728
metrics:
2829
prometheus:

LavalinkServer/src/main/java/lavalink/server/config/AudioPlayerConfiguration.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ class AudioPlayerConfiguration {
4848
if (sources.isYoutube) {
4949
val youtube = YoutubeAudioSourceManager(serverConfig.isYoutubeSearchEnabled)
5050
if (routePlanner != null) {
51-
YoutubeIpRotator.setup(youtube, routePlanner)
51+
val retryLimit = serverConfig.ratelimit?.retryLimit ?: -1
52+
when {
53+
retryLimit < 0 -> YoutubeIpRotator.setup(youtube, routePlanner)
54+
retryLimit == 0 -> YoutubeIpRotator.setup(youtube, routePlanner, Int.MAX_VALUE)
55+
else -> YoutubeIpRotator.setup(youtube, routePlanner, retryLimit)
56+
57+
}
5258
}
5359
val playlistLoadLimit = serverConfig.youtubePlaylistLoadLimit
5460
if (playlistLoadLimit != null) youtube.setPlaylistPageCount(playlistLoadLimit)

LavalinkServer/src/main/java/lavalink/server/config/RateLimitConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ data class RateLimitConfig(
44
var ipBlocks: List<String> = emptyList(),
55
var excludedIps: List<String> = emptyList(),
66
var strategy: String = "RotateOnBan",
7+
var retryLimit: Int = -1,
78
var searchTriggersFail: Boolean = true
89
)

0 commit comments

Comments
 (0)