From 1785059ec832941042c11d8a6b952d57aac8e490 Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 24 Jun 2023 20:01:59 +0100 Subject: [PATCH] d.vx fix --- twitfix.py | 41 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/twitfix.py b/twitfix.py index d47831e..1525b1b 100644 --- a/twitfix.py +++ b/twitfix.py @@ -56,30 +56,7 @@ def twitfix(sub_path): user_agent = request.headers.get('user-agent') match = pathregex.search(sub_path) - if request.url.startswith("https://d.vx"): # Matches d.fx? Try to give the user a direct link - if match.start() == 0: - twitter_url = "https://twitter.com/" + sub_path - if user_agent in generate_embed_user_agents: - print( " ➤ [ D ] d.vx link shown to discord user-agent!") - if request.url.endswith(".mp4") and "?" not in request.url: - - if "?" not in request.url: - clean = twitter_url[:-4] - else: - clean = twitter_url - - vnf,e = vnfFromCacheOrDL(clean) - if vnf == None: - if e is not None: - return message(msgs.failedToScan+msgs.failedToScanExtra+e) - return message(msgs.failedToScan) - return getTemplate("rawvideo.html",vnf,"","",clean,"","","","") - else: - return message("To use a direct MP4 link in discord, remove anything past '?' and put '.mp4' at the end") - else: - print(" ➤ [ R ] Redirect to MP4 using d.fxtwitter.com") - return dir(sub_path) - elif request.url.endswith(".mp4") or request.url.endswith("%2Emp4"): + if request.url.endswith(".mp4") or request.url.endswith("%2Emp4"): twitter_url = "https://twitter.com/" + sub_path if "?" not in request.url: @@ -93,7 +70,21 @@ def twitfix(sub_path): return message(msgs.failedToScan+msgs.failedToScanExtra+e) return message(msgs.failedToScan) return getTemplate("rawvideo.html",vnf,"","",clean,"","","","") - + elif request.url.startswith("https://d.vx"): # Matches d.fx? Try to give the user a direct link + if user_agent in generate_embed_user_agents: + twitter_url = config['config']['url'] + "/"+sub_path + print( " ➤ [ D ] d.vx link shown to discord user-agent!") + if request.url.endswith(".mp4") and "?" not in request.url: + if "?" not in request.url: + clean = twitter_url[:-4] + else: + clean = twitter_url + else: + clean = twitter_url + return redirect(clean+".mp4", 301) + else: + print(" ➤ [ R ] Redirect to MP4 using d.fxtwitter.com") + return dir(sub_path) elif request.url.endswith("/1") or request.url.endswith("/2") or request.url.endswith("/3") or request.url.endswith("/4") or request.url.endswith("%2F1") or request.url.endswith("%2F2") or request.url.endswith("%2F3") or request.url.endswith("%2F4"): twitter_url = "https://twitter.com/" + sub_path