Fix tweet text content appearing in telegram

- Fix video quality sorting
 - Fix screenName being empty
 - Fix img accessed before declaration
 - Hopefully tweet text content shows now in telegram
 - Add flask_cors dependency
 - Remove unnecesary react-helmet garbage
This commit is contained in:
adryd
2022-05-03 10:37:15 -04:00
parent d9f83ae8a1
commit 7bbcd75600
8 changed files with 17 additions and 17 deletions

View File

@ -387,9 +387,9 @@ def tweetInfo(url, tweet="", desc="", thumb="", uploader="", screen_name="", pfp
def link_to_vnf_from_api(video_link):
print(" ➤ [ + ] Attempting to download tweet info from Twitter API")
imgs = ["","","",""] # initialize this in this scope to not cause errors
twid = int(re.sub(r'\?.*$','',video_link.rsplit("/", 1)[-1])) # gets the tweet ID as a int from the passed url
tweet = twitter_api.statuses.show(_id=twid, tweet_mode="extended")
#print(tweet)
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
if tweetType(tweet) == "Video":
@ -397,13 +397,12 @@ def link_to_vnf_from_api(video_link):
best_bitrate = 0
thumb = tweet['extended_entities']['media'][0]['media_url']
for video in tweet['extended_entities']['media'][0]['video_info']['variants']:
if video.content_type == "video/mp4" and video.bitrate > best_bitrate:
url = video.url
if video['content_type'] == "video/mp4" and video['bitrate'] > best_bitrate:
url = video['url']
elif tweetType(tweet) == "Text":
url = ""
thumb = ""
else:
imgs = ["","","",""]
i = 0
for media in tweet['extended_entities']['media']:
imgs[i] = media['media_url_https']
@ -412,7 +411,6 @@ def link_to_vnf_from_api(video_link):
#print(imgs)
url = ""
images= imgs
thumb = tweet['extended_entities']['media'][0]['media_url_https']
qrt = {}
@ -420,7 +418,7 @@ def link_to_vnf_from_api(video_link):
if 'quoted_status' in tweet:
qrt['desc'] = tweet['quoted_status']['full_text']
qrt['handle'] = tweet['quoted_status']['user']['name']
qrt['screenname'] = tweet['quoted_status']['user']['screen_name']
qrt['screen_name'] = tweet['quoted_status']['user']['screen_name']
text = tweet['full_text']
@ -525,7 +523,7 @@ def embed(video_link, vnf, image):
elif vnf['qrt'] == {}: # Check if this is a QRT and modify the description
desc = (desc + likeDisplay)
else:
qrtDisplay = ("\n─────────────\n ➤ QRT of " + vnf['qrt']['handle'] + " (@" + vnf['qrt']['screenname'] + "):\n─────────────\n'" + vnf['qrt']['desc'] + "'")
qrtDisplay = ("\n─────────────\n ➤ QRT of " + vnf['qrt']['handle'] + " (@" + vnf['qrt']['screen_name'] + "):\n─────────────\n'" + vnf['qrt']['desc'] + "'")
desc = (desc + qrtDisplay + likeDisplay)
except:
vnf['likes'] = 0; vnf['rts'] = 0; vnf['time'] = 0