This should get most embeds working again. TODO: fix polls & more testing needed
This commit is contained in:
parent
a350ecbfa5
commit
2a2b598a72
@ -70,7 +70,7 @@ def extractStatus_syndication(url):
|
|||||||
# https://github.com/mikf/gallery-dl/blob/46cae04aa3a113c7b6bbee1bb468669564b14ae8/gallery_dl/extractor/twitter.py#L1784
|
# https://github.com/mikf/gallery-dl/blob/46cae04aa3a113c7b6bbee1bb468669564b14ae8/gallery_dl/extractor/twitter.py#L1784
|
||||||
m = re.search(pathregex, url)
|
m = re.search(pathregex, url)
|
||||||
if m is None:
|
if m is None:
|
||||||
return extractStatus_token(url)
|
raise twExtractError.TwExtractError(400, "Extract error")
|
||||||
twid = m.group(2)
|
twid = m.group(2)
|
||||||
tweet = requests.get("https://cdn.syndication.twimg.com/tweet-result?id=" + twid)
|
tweet = requests.get("https://cdn.syndication.twimg.com/tweet-result?id=" + twid)
|
||||||
|
|
||||||
@ -122,13 +122,29 @@ def extractStatusV2(url):
|
|||||||
# try another token
|
# try another token
|
||||||
continue
|
continue
|
||||||
tweet=output['data']['threaded_conversation_with_injections_v2']['instructions'][0]['entries'][0]["content"]["itemContent"]["tweet_results"]["result"]
|
tweet=output['data']['threaded_conversation_with_injections_v2']['instructions'][0]['entries'][0]["content"]["itemContent"]["tweet_results"]["result"]
|
||||||
|
if '__typename' in tweet and tweet['__typename'] == 'TweetWithVisibilityResults':
|
||||||
|
tweet=tweet['tweet']
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
continue
|
continue
|
||||||
return tweet
|
return tweet
|
||||||
raise twExtractError.TwExtractError(400, "Extract error")
|
raise twExtractError.TwExtractError(400, "Extract error")
|
||||||
|
|
||||||
|
def extractStatusV2Legacy(url):
|
||||||
|
tweet = extractStatusV2(url)
|
||||||
|
if 'errors' in tweet or 'legacy' not in tweet:
|
||||||
|
raise twExtractError.TwExtractError(400, "Extract error")
|
||||||
|
tweet['legacy']['user'] = tweet["core"]["user_results"]["result"]["legacy"]
|
||||||
|
tweet['legacy']['user']['profile_image_url'] = tweet['legacy']['user']['profile_image_url_https']
|
||||||
|
if 'card' in tweet:
|
||||||
|
tweet['legacy']['card'] = tweet['card']['legacy']
|
||||||
|
if 'extended_entities' in tweet['legacy']:
|
||||||
|
tweet['legacy']['extended_entities'] = {'media':tweet['legacy']['extended_entities']['media']}
|
||||||
|
for media in tweet['legacy']['extended_entities']['media']:
|
||||||
|
media['media_url'] = media['media_url_https']
|
||||||
|
return tweet['legacy']
|
||||||
|
|
||||||
def extractStatus(url):
|
def extractStatus(url):
|
||||||
methods=[extractStatus_guestToken,extractStatus_syndication,extractStatus_token]
|
methods=[extractStatus_guestToken,extractStatus_syndication,extractStatus_token,extractStatusV2Legacy]
|
||||||
for method in methods:
|
for method in methods:
|
||||||
try:
|
try:
|
||||||
return method(url)
|
return method(url)
|
||||||
|
17
twitfix.py
17
twitfix.py
@ -108,8 +108,6 @@ 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=[]
|
||||||
@ -399,7 +397,7 @@ def link_to_vnf_from_tweet_data(tweet,video_link):
|
|||||||
isGif=True
|
isGif=True
|
||||||
|
|
||||||
qrtURL = None
|
qrtURL = None
|
||||||
if 'quoted_status' in tweet and 'quoted_status_permalink' in tweet:
|
if 'quoted_status_permalink' in tweet:
|
||||||
qrtURL = tweet['quoted_status_permalink']['expanded']
|
qrtURL = tweet['quoted_status_permalink']['expanded']
|
||||||
|
|
||||||
text = tweet['full_text']
|
text = tweet['full_text']
|
||||||
@ -417,11 +415,14 @@ def link_to_vnf_from_tweet_data(tweet,video_link):
|
|||||||
text = text.replace(eurl["url"],eurl["expanded_url"])
|
text = text.replace(eurl["url"],eurl["expanded_url"])
|
||||||
ttl = None #default
|
ttl = None #default
|
||||||
|
|
||||||
if 'card' in tweet and tweet['card']['name'].startswith('poll'):
|
try:
|
||||||
poll=getPollObject(tweet['card'])
|
if 'card' in tweet and tweet['card']['name'].startswith('poll'):
|
||||||
if tweet['card']['binding_values']['counts_are_final']['boolean_value'] == False:
|
poll=getPollObject(tweet['card'])
|
||||||
ttl = datetime.today().replace(microsecond=0) + timedelta(minutes=1)
|
if tweet['card']['binding_values']['counts_are_final']['boolean_value'] == False:
|
||||||
else:
|
ttl = datetime.today().replace(microsecond=0) + timedelta(minutes=1)
|
||||||
|
else:
|
||||||
|
poll=None
|
||||||
|
except:
|
||||||
poll=None
|
poll=None
|
||||||
|
|
||||||
vnf = tweetInfo(
|
vnf = tweetInfo(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user