Catch case where no image is set

This commit is contained in:
jeancf 2023-06-15 17:40:26 +02:00
parent 17b4f673bb
commit f233592d75

View File

@ -237,20 +237,22 @@ def update_profile(nitter_url, soup, sql, mast_password):
# Download images # Download images
new_avatar = requests.get(nitter_url + new_avatar_url, timeout=HTTPS_REQ_TIMEOUT) if new_avatar_url is not None else None new_avatar = requests.get(nitter_url + new_avatar_url, timeout=HTTPS_REQ_TIMEOUT) if new_avatar_url is not None else None
new_avatar_img = new_avatar.content if new_avatar.status_code == 200 else None if new_avatar is not None:
new_avatar_mime = new_avatar.headers['content-type'] if new_avatar.status_code == 200 else None new_avatar_img = new_avatar.content if new_avatar.status_code == 200 else None
if new_avatar.status_code !=200: new_avatar_mime = new_avatar.headers['content-type'] if new_avatar.status_code == 200 else None
logging.error("Could not download avatar image from " + nitter_url + new_avatar_url) if new_avatar.status_code !=200:
else: logging.error("Could not download avatar image from " + nitter_url + new_avatar_url)
logging.debug("Avatar image downloaded") else:
logging.debug("Avatar image downloaded")
new_banner = requests.get(nitter_url + new_banner_url, timeout=HTTPS_REQ_TIMEOUT) if new_banner_url is not None else None 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 if new_banner is not None:
new_banner_mime = new_banner.headers['content-type'] if new_banner.status_code == 200 else None new_banner_img = new_banner.content if new_banner.status_code == 200 else None
if new_banner.status_code !=200: new_banner_mime = new_banner.headers['content-type'] if new_banner.status_code == 200 else None
logging.error("Could not download banner image from " + nitter_url + new_banner_url) if new_banner.status_code !=200:
else: logging.error("Could not download banner image from " + nitter_url + new_banner_url)
logging.debug("Banner image downloaded") else:
logging.debug("Banner image downloaded")
mastodon = login(mast_password) mastodon = login(mast_password)
# Update profile on Mastodon # Update profile on Mastodon