From 46308d8d31c4cf06ad5dca4c0080b11b54bd94f7 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 25 Mar 2026 17:49:33 -0700 Subject: [PATCH] Fix watchlist artist image not saving for Deezer source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs preventing Deezer artist images in the watchlist: 1. web_server.py: The image fetch called get_artist() which doesn't exist on DeezerClient. Replaced with direct Deezer API call for picture_xl — simple and reliable. 2. music_database.py: update_watchlist_artist_image() only matched spotify_artist_id and itunes_artist_id in the WHERE clause. Deezer artists use deezer_artist_id, so the UPDATE matched zero rows and the image was never saved. Added deezer_artist_id to the WHERE clause. --- database/music_database.py | 4 ++-- web_server.py | 20 ++++++-------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/database/music_database.py b/database/music_database.py index 21edab7c..b90bdaeb 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -6561,8 +6561,8 @@ class MusicDatabase: cursor.execute(""" UPDATE watchlist_artists SET image_url = ?, updated_at = CURRENT_TIMESTAMP - WHERE spotify_artist_id = ? OR itunes_artist_id = ? - """, (image_url, artist_id, artist_id)) + WHERE spotify_artist_id = ? OR itunes_artist_id = ? OR deezer_artist_id = ? + """, (image_url, artist_id, artist_id, artist_id)) conn.commit() return cursor.rowcount > 0 diff --git a/web_server.py b/web_server.py index 76d367d1..4c576ed9 100644 --- a/web_server.py +++ b/web_server.py @@ -33388,20 +33388,12 @@ def add_to_watchlist(): # For numeric IDs, fetch image from the configured fallback source try: if fallback_source == 'deezer': - # Deezer artists have direct image URLs via picture_xl - fallback = _get_metadata_fallback_client() - artist_info = fallback.get_artist_info(str(artist_id)) if hasattr(fallback, 'get_artist_info') else None - image_url = artist_info.get('images', [{}])[0].get('url') if artist_info and artist_info.get('images') else None - # Fallback: try Deezer API directly for picture - if not image_url: - try: - import requests as req - resp = req.get(f'https://api.deezer.com/artist/{artist_id}', timeout=5) - if resp.ok: - dz = resp.json() - image_url = dz.get('picture_xl') or dz.get('picture_big') or dz.get('picture_medium') - except Exception: - pass + # Deezer: fetch artist image directly from API + dz_resp = requests.get(f'https://api.deezer.com/artist/{artist_id}', timeout=5) + if dz_resp.ok: + dz_data = dz_resp.json() + image_url = dz_data.get('picture_xl') or dz_data.get('picture_big') or dz_data.get('picture_medium') + print(f"🖼️ Deezer artist image: {image_url[:60] if image_url else 'None'}") else: # iTunes: look up album entity for artwork itunes_url = f"https://itunes.apple.com/lookup?id={artist_id}&entity=album&limit=5"