From e64dee93498620b0c95b305d72178f23e506dfb6 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 2 Jun 2022 01:09:04 +0100 Subject: [PATCH] Temporary redirect for failing links due to API ratelimiting --- msgs.py | 1 + twitfix.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 msgs.py diff --git a/msgs.py b/msgs.py new file mode 100644 index 0000000..a665bfc --- /dev/null +++ b/msgs.py @@ -0,0 +1 @@ +failedToScan="Failed to scan your link! This may be due to an incorrect link, private account, or the twitter API itself might be having issues (Check here: https://api.twitterstat.us/)\nIt's also possible that Twitter is API limiting me, in which case I can't do anything about it." \ No newline at end of file diff --git a/twitfix.py b/twitfix.py index 50a13ec..9e7ad80 100644 --- a/twitfix.py +++ b/twitfix.py @@ -14,6 +14,7 @@ import urllib.request import combineImg from datetime import date,datetime, timedelta from io import BytesIO +import msgs app = Flask(__name__) CORS(app) @@ -258,7 +259,7 @@ def direct_video(video_link): # Just get a redirect to a MP4 link from any tweet print(" ➤ [ D ] Redirecting to direct URL: " + vnf['url']) except Exception as e: print(e) - return message("Failed to scan your link! This may be due to an incorrect link, private account, or the twitter API itself might be having issues (Check here: https://api.twitterstat.us/)") + return message(msgs.failedToScan) else: return redirect(cached_vnf['url'], 301) print(" ➤ [ D ] Redirecting to direct URL: " + vnf['url']) @@ -273,7 +274,7 @@ def direct_video_link(video_link): # Just get a redirect to a MP4 link from any print(" ➤ [ D ] Redirecting to direct URL: " + vnf['url']) except Exception as e: print(e) - return message("Failed to scan your link! This may be due to an incorrect link, private account, or the twitter API itself might be having issues (Check here: https://api.twitterstat.us/)") + return message(msgs.failedToScan) else: return cached_vnf['url'] print(" ➤ [ D ] Redirecting to direct URL: " + vnf['url']) @@ -289,7 +290,7 @@ def embed_video(video_link, image=0): # Return Embed from any tweet link except Exception as e: print(e) - return message("Failed to scan your link! This may be due to an incorrect link, private account, or the twitter API itself might be having issues (Check here: https://api.twitterstat.us/)") + return redirect(video_link) #message(msgs) else: return embed(video_link, cached_vnf, image) @@ -543,7 +544,7 @@ def embedCombined(video_link): except Exception as e: print(e) - return message("Failed to scan your link! This may be due to an incorrect link, private account, or the twitter API itself might be having issues (Check here: https://api.twitterstat.us/)") + return message(msgs.failedToScan) else: return embedCombinedVnf(video_link, cached_vnf)