From df8537e811e42ff7b09ac7b939e48cbb072b7887 Mon Sep 17 00:00:00 2001 From: MMaker Date: Mon, 3 Mar 2025 22:03:32 -0500 Subject: [PATCH] Remove play button for videos not downloaded --- app.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 8eb14b4..2d9d9e2 100644 --- a/app.py +++ b/app.py @@ -366,7 +366,11 @@ def proxy(video_id): og_tags_str = "\n".join(str(tag) for tag in og_tags if tag.get("property") not in ["og:site_name"]) og_tags_str += '\n' og_tags_str += f'\n' - if 'twitterbot' in request_user_agent: + + # Discord seems to ignore video URLs when Twitter meta tags are present, + # so in addition to including these when the User Agent is a Twitter bot, + # we also include them when the video is too long to download in order to remove the play button. + if 'twitterbot' in request_user_agent or not download_allowed: logger.info(f"{video_id}: Twitterbot detected - adding Twitter tags") og_tags_str += f'\n' og_tags_str += '\n'