Projects STRLCPY snscrape Commits 5103a33a
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    snscrape/modules/twitter.py
    skipped 864 lines
    865 865   kwargs['cashtags'] = [o['text'] for o in tweet['entities']['symbols']]
    866 866   if card:
    867 867   kwargs['card'] = card
    868  - if hasattr(card, 'url') and '//t.co/' in card.url and 'tcooutlinks' in kwargs:
     868 + if hasattr(card, 'url') and '//t.co/' in card.url:
    869 869   # Try to convert the URL to the non-shortened/t.co one
    870  - try:
    871  - i = kwargs['tcooutlinks'].index(card.url)
    872  - except ValueError:
    873  - _logger.warning(f'Could not find card URL in tcooutlinks on tweet {tweetId}')
     870 + # Retweets inherit the card but not the outlinks; try to get them from the retweeted tweet instead in that case.
     871 + if 'tcooutlinks' in kwargs and card.url in kwargs['tcooutlinks']:
     872 + card.url = kwargs['outlinks'][kwargs['tcooutlinks'].index(card.url)]
     873 + elif retweetedTweet and retweetedTweet.tcooutlinks and card.url in retweetedTweet.tcooutlinks:
     874 + card.url = retweetedTweet.outlinks[retweetedTweet.tcooutlinks.index(card.url)]
    874 875   else:
    875  - card.url = kwargs['outlinks'][i]
     876 + _logger.warning(f'Could not translate t.co card URL on tweet {tweetId}')
    876 877   return Tweet(**kwargs)
    877 878   
    878 879   def _make_medium(self, medium, tweetId):
    skipped 809 lines
Please wait...
Page is in error, reload to recover