From ee403a5301aa634163808fbc09b070085878277b Mon Sep 17 00:00:00 2001 From: jeancf Date: Thu, 15 Jun 2023 17:10:18 +0200 Subject: [PATCH] Handle AttributeError --- twoot.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/twoot.py b/twoot.py index 9af3d24..6e5ff64 100755 --- a/twoot.py +++ b/twoot.py @@ -193,10 +193,16 @@ def update_profile(nitter_url, soup, sql, mast_password): db = sql.cursor() # Extract avatar picture address - new_avatar_url = soup.find('div', class_='profile-card-info').findChild('a').findChild('img').get('src') + 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 - new_banner_url = soup.find('div', class_='profile-banner').findChild('a').findChild('img').get('src') + 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'],))