Skip to content

Commit

Permalink
Reapply context filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Jul 12, 2024
1 parent c9e67c4 commit 0fca093
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -359,6 +360,11 @@ public Client[] getClients() {
return clients;
}

@NotNull
public YoutubeHttpContextFilter getContextFilter() {
return contextFilter;
}

@NotNull
public HttpInterfaceManager getHttpInterfaceManager() {
return httpInterfaceManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0fca093

Please sign in to comment.