From 1b215bb5b70417bff89279b0d973a9d06b0016c8 Mon Sep 17 00:00:00 2001 From: Devoxin Date: Fri, 12 Jul 2024 01:41:42 +0100 Subject: [PATCH] Don't apply token/UA/visitor ID to googlevideo URLs --- .../youtube/http/YoutubeHttpContextFilter.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/dev/lavalink/youtube/http/YoutubeHttpContextFilter.java b/common/src/main/java/dev/lavalink/youtube/http/YoutubeHttpContextFilter.java index aa6227d..e719716 100644 --- a/common/src/main/java/dev/lavalink/youtube/http/YoutubeHttpContextFilter.java +++ b/common/src/main/java/dev/lavalink/youtube/http/YoutubeHttpContextFilter.java @@ -67,13 +67,15 @@ public void onRequest(HttpClientContext context, String userAgent = context.getAttribute(ATTRIBUTE_USER_AGENT_SPECIFIED, String.class); - if (userAgent != null) { - request.setHeader("User-Agent", userAgent); - request.setHeader("X-Goog-Visitor-Id", tokenTracker.getVisitorId()); - context.removeAttribute(ATTRIBUTE_USER_AGENT_SPECIFIED); - } + if (!request.getURI().getHost().contains("googlevideo")) { + if (userAgent != null) { + request.setHeader("User-Agent", userAgent); + request.setHeader("X-Goog-Visitor-Id", tokenTracker.getVisitorId()); + context.removeAttribute(ATTRIBUTE_USER_AGENT_SPECIFIED); + } - oauth2Handler.applyToken(request); + oauth2Handler.applyToken(request); + } // try { // URI uri = new URIBuilder(request.getURI())