From 36298925ac3d56456e58aec416caf37b2665fb30 Mon Sep 17 00:00:00 2001 From: JCF Date: Thu, 15 Jun 2023 20:07:39 +0200 Subject: [PATCH] Fixed undefined variable error --- twoot.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/twoot.py b/twoot.py index 624780c..4c0e261 100755 --- a/twoot.py +++ b/twoot.py @@ -233,6 +233,11 @@ def update_profile(nitter_url, soup, sql, mast_password): if changed: logging.info('updating profile on Mastodon') + new_avatar_img = None + new_avatar_mime = None + new_banner_img = None + new_banner_mime = None + # Download images new_avatar = requests.get(nitter_url + new_avatar_url, timeout=HTTPS_REQ_TIMEOUT) if new_avatar_url is not None else None if new_avatar is not None: @@ -253,13 +258,11 @@ def update_profile(nitter_url, soup, sql, mast_password): logging.debug("Banner image downloaded") mastodon = login(mast_password) + # Update profile on Mastodon - # media.content, mime_type=media.headers['content-type'] try: - if new_avatar_img is not None: - mastodon.account_update_credentials(avatar=new_avatar_img, avatar_mime_type=new_avatar_mime) - if new_banner_img is not None: - mastodon.account_update_credentials(header=new_banner_img, header_mime_type=new_banner_mime) + mastodon.account_update_credentials(avatar=new_avatar_img, avatar_mime_type=new_avatar_mime, header=new_banner_img, header_mime_type=new_banner_mime) + logging.debug("Images uploaded") except Exception as e: logging.error("Could not update profile") logging.error(e)