From 8bd8aeec2999ef65ef8baa4fe090c0075a632f8c Mon Sep 17 00:00:00 2001 From: jeancf Date: Sun, 16 Jul 2023 12:48:26 +0200 Subject: [PATCH] Moved db lookup to the right section --- twoot.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/twoot.py b/twoot.py index 80b4832..c2f13fe 100755 --- a/twoot.py +++ b/twoot.py @@ -1113,15 +1113,6 @@ 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, @@ -1131,7 +1122,7 @@ def main(argv): "tweet_text": tweet_text, "video": video_file, "photos": photos, - "replied-to-tweet": replied_to_toot, + "replied_to_tweet": replied_to_tweet, } tweets.append(tweet) @@ -1199,6 +1190,16 @@ def main(argv): TypeError): # Media cannot be uploaded (invalid format, dead link, etc.) pass + # Find in database toot id of replied_to_tweet + replied_to_toot = None + if tweet['replied_to_tweet'] is not None: + logging.debug("Seazrching db for replied-to-tweet " + tweet['replied_to_tweet']) + db.execute("SELECT toot_id FROM toots WHERE tweet_id=?", tweet['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) + # Post toot toot = {} try: