Proper fix for API
This commit is contained in:
parent
c775005227
commit
a1b6ebe73e
13
twitfix.py
13
twitfix.py
@ -108,6 +108,8 @@ def twitfix(sub_path):
|
|||||||
twitter_url = "https://twitter.com/" + sub_path
|
twitter_url = "https://twitter.com/" + sub_path
|
||||||
try:
|
try:
|
||||||
tweet = twExtract.extractStatusV2(twitter_url)
|
tweet = twExtract.extractStatusV2(twitter_url)
|
||||||
|
if '__typename' in tweet and tweet['__typename'] == 'TweetWithVisibilityResults':
|
||||||
|
tweet=tweet['tweet']
|
||||||
tweetL = tweet["legacy"]
|
tweetL = tweet["legacy"]
|
||||||
userL = tweet["core"]["user_results"]["result"]["legacy"]
|
userL = tweet["core"]["user_results"]["result"]["legacy"]
|
||||||
media=[]
|
media=[]
|
||||||
@ -118,12 +120,13 @@ def twitfix(sub_path):
|
|||||||
for i in tmedia:
|
for i in tmedia:
|
||||||
if "video_info" in i:
|
if "video_info" in i:
|
||||||
# find the highest bitrate
|
# find the highest bitrate
|
||||||
highest = 0
|
highest = -1
|
||||||
|
besturl=""
|
||||||
for j in i["video_info"]["variants"]:
|
for j in i["video_info"]["variants"]:
|
||||||
if "bitrate" in j:
|
if j['content_type'] == "video/mp4" and j['bitrate'] > best_bitrate:
|
||||||
if j["bitrate"] > highest:
|
besturl = j['url']
|
||||||
highest = j["bitrate"]
|
best_bitrate = i['bitrate']
|
||||||
media.append(j["url"])
|
media.append(besturl)
|
||||||
else:
|
else:
|
||||||
media.append(i["media_url_https"])
|
media.append(i["media_url_https"])
|
||||||
if "hashtags" in tweetL["extended_entities"]:
|
if "hashtags" in tweetL["extended_entities"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user