Skip to content

Commit

Permalink
In parse_tweet add dedicated error message for "legacy" absence
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Jul 18, 2024
1 parent 945fa2d commit 46aebaa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion avtdl/plugins/twitter/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ def parse_tweet(tweet_results: dict) -> TwitterRecord:
raise ValueError(f'failed to parse tweet: {e}')
url = tweet_url_by_id(user.handle, rest_id)

legacy = tweet_result['legacy']
legacy = tweet_result.get('legacy')
if legacy is None:
raise ValueError(f'failed to parse tweet: no "legacy" field in tweet_result')

published = tweet_timestamp(rest_id) or dateutil.parser.parse(legacy['created_at'])

Expand Down

0 comments on commit 46aebaa

Please sign in to comment.