Skip to content

Commit

Permalink
Print stacktrace on failure to parse tweet in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Oct 29, 2024
1 parent d07fbff commit c44192c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion avtdl/plugins/twitter/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def parse_tweet(tweet_results: dict) -> TwitterRecord:

legacy = tweet_result.get('legacy')
if legacy is None:
raise ValueError(f'failed to parse tweet: no "legacy" field in tweet_result')
raise ValueError(f'failed to parse tweet: no "legacy" field in tweet_result for {url}')

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

Expand Down
4 changes: 3 additions & 1 deletion avtdl/plugins/twitter/twitter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import datetime
import json
import traceback
from abc import abstractmethod
from typing import Any, List, Optional, Sequence, Tuple

Expand Down Expand Up @@ -76,7 +77,8 @@ async def _parse_entries(self, page: str) -> Tuple[List[TwitterRecord], Optional
try:
record = parse_tweet(tweet_result)
except Exception as e:
self.logger.exception(f'error parsing tweet: {e}')
self.logger.warning(f'error parsing tweet: {e}')
self.logger.debug(f'stack trace: {traceback.format_exc()}')
self.logger.debug(f'raw tweet_result: {tweet_result}')
else:
records.append(record)
Expand Down

0 comments on commit c44192c

Please sign in to comment.