Handle AttributeError

This commit is contained in:
jeancf 2023-06-15 17:10:18 +02:00
parent 7e4a7d8576
commit ee403a5301

View File

@ -193,10 +193,16 @@ def update_profile(nitter_url, soup, sql, mast_password):
db = sql.cursor()
# Extract avatar picture address
try:
new_avatar_url = soup.find('div', class_='profile-card-info').findChild('a').findChild('img').get('src')
except AttributeError:
new_avatar_url = None
# Extract banner picture address
try:
new_banner_url = soup.find('div', class_='profile-banner').findChild('a').findChild('img').get('src')
except AttributeError:
new_banner_url = None
# Get the original urls of the avatar and banner pictures on the account profile
db.execute("SELECT avatar_url, banner_url FROM profiles WHERE mastodon_instance=? AND mastodon_account=?", (TOML['config']['mastodon_instance'], TOML['config']['mastodon_user'],))