Handling tweet-link exception

This commit is contained in:
jeancf 2023-07-11 19:45:53 +02:00
parent f4addcf5a3
commit 89b6068a04

View File

@ -885,8 +885,13 @@ def main(argv):
in_db_cnt = 0
for status in timeline:
# Extract tweet ID and status ID
tweet_id = status.find('a', class_='tweet-link').get('href').strip('#m')
status_id = tweet_id.split('/')[3]
try:
tweet_id = status.find('a', class_='tweet-link').get('href').strip('#m')
status_id = tweet_id.split('/')[3]
except Exception as e:
logging.critical('Malformed timeline downloaded from nitter instance')
logging.debug(e)
shutdown(-1)
logging.debug('processing tweet %s', tweet_id)
@ -995,8 +1000,8 @@ def main(argv):
timezone_display = pytz.timezone(TOML['options']['tweet_timezone'])
else: # Use local timezone by default
timezone_display = datetime.now().astimezone().tzinfo
logging.debug("Timestamp UTC " + str(timestamp))
logging.debug("Timezone to use" + str(timezone_display))
logging.debug("Timestamp UTC: " + str(timestamp))
logging.debug("Timezone to use: " + str(timezone_display))
timestamp_display = pytz.utc.localize(timestamp).astimezone(timezone_display)
logging.debug("Timestamp converted " + str(timestamp_display))