Squash bugs

This commit is contained in:
jeancf 2023-07-16 16:15:50 +02:00
parent 061db3f729
commit 24e9bd5691

View File

@ -175,7 +175,7 @@ Only used by `get_timeline()`.
""" """
def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item): def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
# Add first item to timeline # Add first item to timeline
timeline = [(thread_url, first_item)] timeline = [(None, first_item)]
logging.debug("Downloading tweets in thread from separate page") logging.debug("Downloading tweets in thread from separate page")
# Download page with thread # Download page with thread
@ -213,13 +213,16 @@ def _get_rest_of_thread(session, headers, nitter_url, thread_url, first_item):
for item in list: for item in list:
timeline.append((previous_tweet_url, item)) timeline.append((previous_tweet_url, item))
# Get the url of the tweet # Get the url of the tweet
previous_tweet_tag = item.find('a', class_='tweet-link') tweet_link_tag = item.find('a', class_='tweet-link')
if previous_tweet_url is None: if tweet_link_tag is not None:
previous_tweet_url = previous_tweet_tag.get('href').strip('#m') previous_tweet_url = tweet_link_tag.get('href').strip('#m')
else:
previous_tweet_url = None
logging.error('Thread tweet is missing link tag') logging.error('Thread tweet is missing link tag')
# return timeline in reverse chronological order # return timeline in reverse chronological order
return timeline.reverse() timeline.reverse()
return timeline
""" """
@ -1195,12 +1198,14 @@ def main(argv):
# Find in database toot id of replied_to_tweet # Find in database toot id of replied_to_tweet
replied_to_toot = None replied_to_toot = None
if tweet['replied_to_tweet'] is not None: if tweet['replied_to_tweet'] is not None:
logging.debug("Searching db for replied-to-tweet " + tweet['replied_to_tweet']) logging.debug("Searching db for toot corresponding to replied-to-tweet " + tweet['replied_to_tweet'])
db.execute("SELECT toot_id FROM toots WHERE tweet_id=?", [tweet['replied_to_tweet']]) db.execute("SELECT toot_id FROM toots WHERE tweet_id=?", [tweet['replied_to_tweet']])
replied_to_toot = db.fetchone() replied_to_toot = db.fetchone()
if replied_to_toot is None: if replied_to_toot is None:
logging.warning('Replied-to tweet %s not found in database', tweet['replied_to_tweet']) logging.warning('Replied-to tweet %s not found in database', tweet['replied_to_tweet'])
else:
logging.debug("toot %s found", replied_to_toot)
# Post toot # Post toot
toot = {} toot = {}