Merge pull request #48 from adryd325/patch-1

Re-add quality sorting
This commit is contained in:
Robin Universe 2022-03-19 20:12:46 -05:00 committed by GitHub
commit d9f83ae8a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -393,12 +393,12 @@ def link_to_vnf_from_api(video_link):
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":
if tweet['extended_entities']['media'][0]['video_info']['variants'][-1]['content_type'] == "video/mp4":
url = tweet['extended_entities']['media'][0]['video_info']['variants'][-1]['url']
thumb = tweet['extended_entities']['media'][0]['media_url']
else:
url = tweet['extended_entities']['media'][0]['video_info']['variants'][-2]['url']
if tweet['extended_entities']['media'][0]['video_info']['variants']:
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
elif tweetType(tweet) == "Text":
url = ""
thumb = ""