Fix for Discord user agent for files

This commit is contained in:
MMaker 2025-02-27 15:40:34 -05:00
parent 2ade81b3be
commit 9905d91479
Signed by: mmaker
GPG Key ID: CCE79B8FEDA40FB2

5
app.py
View File

@ -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)