From a51876a82943567107ef9c777cfa5ffd9c89f060 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 23 Jul 2022 16:34:36 +0100 Subject: [PATCH] Fix twitter api failing for direct video linking --- twitfix.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/twitfix.py b/twitfix.py index 1341cbb..d8398c7 100644 --- a/twitfix.py +++ b/twitfix.py @@ -72,7 +72,11 @@ def twitfix(sub_path): print( " ➤ [ D ] d.vx link shown to discord user-agent!") if request.url.endswith(".mp4") and "?" not in request.url: # TODO: Cache this, but not for too long as disk space can fill up - vid = requests.get(direct_video_link(twitter_url)) + if "?" not in request.url: + clean = twitter_url[:-4] + else: + clean = twitter_url + vid = requests.get(direct_video_link(clean)) return Response(vid.content,mimetype="video/mp4") else: return message("To use a direct MP4 link in discord, remove anything past '?' and put '.mp4' at the end") @@ -98,7 +102,7 @@ def twitfix(sub_path): else: clean = twitter_url # TODO: Cache this, but not for too long as disk space can fill up - vid = requests.get(direct_video_link(twitter_url)) + vid = requests.get(direct_video_link(clean)) return Response(vid.content,mimetype="video/mp4") # elif request.url.endswith(".json") or request.url.endswith("%2Ejson"):