Fix watchlist artist image not saving for Deezer source
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.
This commit is contained in:
parent
de8f758596
commit
46308d8d31
2 changed files with 8 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in a new issue