diff --git a/common/src/main/java/dev/lavalink/youtube/YoutubeAudioSourceManager.java b/common/src/main/java/dev/lavalink/youtube/YoutubeAudioSourceManager.java index 59ba7a0..8dcbb19 100644 --- a/common/src/main/java/dev/lavalink/youtube/YoutubeAudioSourceManager.java +++ b/common/src/main/java/dev/lavalink/youtube/YoutubeAudioSourceManager.java @@ -66,6 +66,7 @@ public class YoutubeAudioSourceManager implements AudioSourceManager { protected final boolean allowDirectPlaylistIds; protected final Client[] clients; + protected YoutubeHttpContextFilter contextFilter; protected YoutubeOauth2Handler oauth2Handler; protected SignatureCipherManager cipherManager; @@ -129,7 +130,7 @@ public YoutubeAudioSourceManager(boolean allowSearch, this.oauth2Handler = new YoutubeOauth2Handler(httpInterfaceManager); - YoutubeHttpContextFilter contextFilter = new YoutubeHttpContextFilter(); + contextFilter = new YoutubeHttpContextFilter(); contextFilter.setTokenTracker(new YoutubeAccessTokenTracker(httpInterfaceManager)); contextFilter.setOauth2Handler(oauth2Handler); @@ -359,6 +360,11 @@ public Client[] getClients() { return clients; } + @NotNull + public YoutubeHttpContextFilter getContextFilter() { + return contextFilter; + } + @NotNull public HttpInterfaceManager getHttpInterfaceManager() { return httpInterfaceManager; diff --git a/plugin/src/main/java/dev/lavalink/youtube/plugin/YoutubePluginLoader.java b/plugin/src/main/java/dev/lavalink/youtube/plugin/YoutubePluginLoader.java index de1bd14..419738d 100644 --- a/plugin/src/main/java/dev/lavalink/youtube/plugin/YoutubePluginLoader.java +++ b/plugin/src/main/java/dev/lavalink/youtube/plugin/YoutubePluginLoader.java @@ -167,7 +167,7 @@ public AudioPlayerManager configure(AudioPlayerManager audioPlayerManager) { final int retryLimit = ratelimitConfig.getRetryLimit(); final YoutubeIpRotatorSetup rotator = new YoutubeIpRotatorSetup(routePlanner) .forConfiguration(source.getHttpInterfaceManager(), false) - .withMainDelegateFilter(null); // Necessary to avoid NPEs. + .withMainDelegateFilter(source.getContextFilter()); if (retryLimit == 0) { rotator.withRetryLimit(Integer.MAX_VALUE);