nya
Signed-off-by: Chloe Carver-Brown <admin@twxtter.com>
This commit is contained in:
parent
0fe2027bc1
commit
b795a9fe82
23
twitfix.py
23
twitfix.py
|
@ -23,6 +23,10 @@ import urllib.parse
|
|||
import urllib.request
|
||||
from datetime import date
|
||||
|
||||
class TwitterUserProtected(Exception):
|
||||
pass
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
|
@ -493,6 +497,8 @@ def direct_video(video_link): # Just get a redirect to a MP4 link from any twee
|
|||
addVnfToLinkCache(video_link, vnf)
|
||||
return redirect(vnf["url"], 301)
|
||||
print(" ➤ [ D ] Redirecting to direct URL: " + vnf["url"])
|
||||
except TwitterUserProtected:
|
||||
return message("This user is guarding their tweets!")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return message("Failed to scan your link!")
|
||||
|
@ -511,6 +517,8 @@ def direct_video_link(
|
|||
addVnfToLinkCache(video_link, vnf)
|
||||
return vnf["url"]
|
||||
print(" ➤ [ D ] Redirecting to direct URL: " + vnf["url"])
|
||||
except TwitterUserProtected:
|
||||
return message("This user is guarding their tweets!")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return message("Failed to scan your link!")
|
||||
|
@ -600,6 +608,13 @@ def link_to_vnf_from_api(video_link):
|
|||
tweet = twitter_api.statuses.show(_id=twid, tweet_mode="extended")
|
||||
# For when I need to poke around and see what a tweet looks like
|
||||
# print(tweet)
|
||||
protected = tweet['user']['protected']
|
||||
if protected:
|
||||
raise TwitterUserProtected()
|
||||
|
||||
text = tweet["full_text"]
|
||||
nsfw = tweet.get("possibly_sensitive", False)
|
||||
qrt = {}
|
||||
imgs = ["", "", "", "", ""]
|
||||
print(" ➤ [ + ] Tweet Type: " + tweetType(tweet))
|
||||
# Check to see if tweet has a video, if not, make the url passed to the VNF the first t.co link in the tweet
|
||||
|
@ -631,8 +646,6 @@ def link_to_vnf_from_api(video_link):
|
|||
images = imgs
|
||||
thumb = tweet["extended_entities"]["media"][0]["media_url_https"]
|
||||
|
||||
qrt = {}
|
||||
|
||||
if "quoted_status" in tweet:
|
||||
qrt["desc"] = tweet["quoted_status"]["full_text"]
|
||||
qrt["handle"] = tweet["quoted_status"]["user"]["name"]
|
||||
|
@ -683,6 +696,9 @@ def link_to_vnf(video_link): # Return a VideoInfo object or die trying
|
|||
if config["config"]["method"] == "hybrid":
|
||||
try:
|
||||
return link_to_vnf_from_api(video_link)
|
||||
except TwitterUserProtected:
|
||||
print(" ➤ [ X ] User is protected, stop.")
|
||||
raise
|
||||
except Exception as e:
|
||||
print(" ➤ [ !!! ] API Failed")
|
||||
print(e)
|
||||
|
@ -690,6 +706,9 @@ def link_to_vnf(video_link): # Return a VideoInfo object or die trying
|
|||
elif config["config"]["method"] == "api":
|
||||
try:
|
||||
return link_to_vnf_from_api(video_link)
|
||||
except TwitterUserProtected:
|
||||
print(" ➤ [ X ] User is protected, stop.")
|
||||
raise
|
||||
except Exception as e:
|
||||
print(" ➤ [ X ] API Failed")
|
||||
print(e)
|
||||
|
|
Reference in New Issue