Fix crash on empty tweet entries in timelines

Fixes #620
This commit is contained in:
JustAnotherArchivist
2023-01-13 09:01:15 +00:00
parent 27374285a2
commit bf0e720b5a

View File

@@ -1387,6 +1387,9 @@ class _TwitterAPIScraper(snscrape.base.Scraper):
for entry in instruction['entries']: for entry in instruction['entries']:
if entry['entryId'].startswith('tweet-'): if entry['entryId'].startswith('tweet-'):
if entry['content']['entryType'] == 'TimelineTimelineItem' and entry['content']['itemContent']['itemType'] == 'TimelineTweet': if entry['content']['entryType'] == 'TimelineTimelineItem' and entry['content']['itemContent']['itemType'] == 'TimelineTweet':
if 'result' not in entry['content']['itemContent']['tweet_results']:
_logger.warning(f'Skipping empty tweet entry {entry["entryId"]}')
continue
yield self._graphql_timeline_tweet_item_result_to_tweet(entry['content']['itemContent']['tweet_results']['result']) yield self._graphql_timeline_tweet_item_result_to_tweet(entry['content']['itemContent']['tweet_results']['result'])
else: else:
logger.warning('Got unrecognised timeline tweet item(s)') logger.warning('Got unrecognised timeline tweet item(s)')