Convert t.co card URLs to unshortened when possible

This commit is contained in:
JustAnotherArchivist
2022-02-17 01:50:15 +00:00
parent 878f2a3c7a
commit 2f9c0457df

View File

@@ -600,6 +600,14 @@ class _TwitterAPIScraper(snscrape.base.Scraper):
kwargs['cashtags'] = [o['text'] for o in tweet['entities']['symbols']]
if card:
kwargs['card'] = card
# Try to convert the URL to the non-shortened/t.co one
try:
i = kwargs['tcooutlinks'].index(card.url)
except ValueError:
_logger.warning('Could not find card URL in tcooutlinks')
pass
else:
card.url = kwargs['outlinks'][i]
return Tweet(**kwargs)
def _make_card(self, card, apiType):