From e62e5634e043c6383d1f0114117daf02dcb75698 Mon Sep 17 00:00:00 2001 From: jeancf Date: Sun, 16 Jul 2023 12:37:26 +0200 Subject: [PATCH] Added db lookup for replied_to_tweet --- twoot.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/twoot.py b/twoot.py index c9f87a8..80b4832 100755 --- a/twoot.py +++ b/twoot.py @@ -959,7 +959,7 @@ def main(argv): tweets = [] out_date_cnt = 0 in_db_cnt = 0 - for reply_to, status in timeline: + for replied_to_tweet, 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] @@ -1113,6 +1113,15 @@ def main(argv): # Extract posix path of first video file in list video_file = video_file_list[0].absolute().as_posix() + # Find in database toot id of replied_to_tweet + replied_to_toot = None + if replied_to_tweet is not None: + db.execute("SELECT twoot_id FROM toots WHERE tweet_id=?", replied_to_tweet) + replied_to_toot = db.fetchone() + + if replied_to_toot is None: + logging.warning('Replied-to tweet %s not found in database', replied_to_tweet) + # Add dictionary with content of tweet to list tweet = { "author": author, @@ -1122,7 +1131,7 @@ def main(argv): "tweet_text": tweet_text, "video": video_file, "photos": photos, - "reply-to": reply_to, + "replied-to-tweet": replied_to_toot, } tweets.append(tweet)