From 46aebaae206238a7c13646639b0add9cfe6078b2 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 18 Jul 2024 05:25:41 +0300 Subject: [PATCH] In parse_tweet add dedicated error message for "legacy" absence --- avtdl/plugins/twitter/extractors.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/avtdl/plugins/twitter/extractors.py b/avtdl/plugins/twitter/extractors.py index aaa7fea..2910c52 100644 --- a/avtdl/plugins/twitter/extractors.py +++ b/avtdl/plugins/twitter/extractors.py @@ -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'])