From 4cfb1db7d0d4b4f1eac9bc64df82622c63b9b68c Mon Sep 17 00:00:00 2001 From: sherl Date: Wed, 17 Sep 2025 01:52:45 +0200 Subject: [PATCH] fix: handle url rewrite when querying wrong endpoint materialious is guilty of this --- views.py | 4 ++++ ythdd_extractor.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/views.py b/views.py index c09b126..8c7e833 100644 --- a/views.py +++ b/views.py @@ -36,6 +36,10 @@ def ggphtProxy(received_request): prefix = "https://yt3.ggpht.com/" + # fix for how materialious fetches avatars + if received_request.startswith("guc/"): + return gucProxy(received_request.removeprefix("guc/")) + ggpht = requests.get(prefix + received_request, headers=ythdd_globals.getHeaders(caller='proxy'), stream=True) ggpht.raw.decode_content = True response = Response(ggpht.raw, mimetype=ggpht.headers['content-type'], status=ggpht.status_code) diff --git a/ythdd_extractor.py b/ythdd_extractor.py index bab0246..0993d06 100644 --- a/ythdd_extractor.py +++ b/ythdd_extractor.py @@ -276,8 +276,8 @@ def generateChannelAvatarsFromUrl(url: str, proxied: bool = True) -> list: # Generates channel avatars at default sizes. # avatar urls for channels in search results start with //yt3.ggpht.com/ - if url.startswith("//yt3.ggpht.com/"): - url = url.replace("//yt3.ggpht.com/", "https://yt3.ggpht.com/") + if url.startswith("//"): + url = "https:" + url avatars = [] if not url.startswith("https://yt3.ggpht.com/") and not url.startswith("https://yt3.googleusercontent.com/"):