From 870a1ee74568464c9a95a2acb3fae26bdf3ec0b4 Mon Sep 17 00:00:00 2001 From: jeancf Date: Thu, 15 Jun 2023 14:23:41 +0200 Subject: [PATCH] Added debug messages --- twoot.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/twoot.py b/twoot.py index 0dc37b4..fac1ba0 100755 --- a/twoot.py +++ b/twoot.py @@ -180,11 +180,6 @@ def update_profile(nitter_url, soup, sql, mast_password): """ # TODO Check if TOML option to update profile is set - # @noirextreme banner before https://nitter.net/pic/https%3A%2F%2Fpbs.twimg.com%2Fprofile_banners%2F57014511%2F1525787041%2F1500x500 - # after https://nitter.net/pic/https%3A%2F%2Fpbs.twimg.com%2Fprofile_banners%2F57014511%2F1686822924%2F1500x500 - # @noirextreme avatar before https://pbs.twimg.com/profile_images/1081778074/Twitter_400x400.png - # after - db = sql.cursor() # Extract avatar picture address @@ -216,6 +211,7 @@ def update_profile(nitter_url, soup, sql, mast_password): db.execute("INSERT INTO profiles (mastodon_account, avatar_url, banner_url) VALUES (?, ?, ?)", (TOML['config']['mastodon_user'], "", "")) sql.commit() changed = True + logging.debug("added new profile to database") mastodon = None @@ -228,13 +224,13 @@ def update_profile(nitter_url, soup, sql, mast_password): new_avatar_img = new_avatar.content if new_avatar.status_code == 200 else None new_avatar_mime = new_avatar.headers['content-type'] if new_avatar.status_code == 200 else None if new_avatar.status_code !=200: - logging.error("Could not download image from " + nitter_url + new_avatar_url) + logging.error("Could not download avatar image from " + nitter_url + new_avatar_url) new_banner = requests.get(nitter_url + new_banner_url, timeout=HTTPS_REQ_TIMEOUT) if new_banner_url is not None else None new_banner_img = new_banner.content if new_banner.status_code == 200 else None new_banner_mime = new_banner.headers['content-type'] if new_banner.status_code == 200 else None if new_banner.status_code !=200: - logging.error("Could not download image from " + nitter_url + new_banner_url) + logging.error("Could not download banner image from " + nitter_url + new_banner_url) mastodon = login(mast_password) # Update profile on Mastodon @@ -248,8 +244,8 @@ def update_profile(nitter_url, soup, sql, mast_password): # Add urls to database db.execute("UPDATE profiles SET avatar_url=?, banner_url=? WHERE mastodon_account=?", (new_avatar_url, new_banner_url, TOML['config']['mastodon_user'])) sql.commit() + logging.debug("updated profile on database") - exit(5) return mastodon def deredir_url(url): @@ -832,9 +828,9 @@ def main(argv): logging.debug('Nitter page downloaded successfully from ' + url) # DEBUG: Save page to file - of = open(TOML['config']['twitter_account'] + '.html', 'w') - of.write(twit_account_page.text) - of.close() + # of = open(TOML['config']['twitter_account'] + '.html', 'w') + # of.write(twit_account_page.text) + # of.close() # Make soup soup = BeautifulSoup(twit_account_page.text, 'html.parser')