From 9905d914796b1853266665518e9eb0b7ac655b5d Mon Sep 17 00:00:00 2001 From: MMaker Date: Thu, 27 Feb 2025 15:40:34 -0500 Subject: [PATCH] Fix for Discord user agent for files --- app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 417a311..1e8d48e 100644 --- a/app.py +++ b/app.py @@ -293,8 +293,9 @@ def cdn_redirect(video_id): Only responds to requests from Discord bots. """ logger.info(f"{video_id}: CDN redirect request received") - request_user_agent = request.headers.get('User-Agent', '').lower() - if 'discordbot' not in request_user_agent: + request_user_agent = request.headers.get('User-Agent', '') + # Discord uses a more realistic user agent for file requests + if 'Firefox/38.0' not in request_user_agent and 'Macintosh' not in request_user_agent: logger.info(f"{video_id}: Video CDN redirect ignored due to user agent ({request_user_agent})") return Response("Video not found", status=404)