Backfill missing watchlist artist images during scan

The image update code only checked Spotify's images array format,
missing iTunes direct image_url. Also used spotify_artist_id for
DB lookup which missed Deezer-only artists. Now handles both image
formats and tries all provider IDs for the DB update.

Old Deezer watchlist artists missing images will get backfilled
on the next watchlist scan automatically.
This commit is contained in:
Broque Thomas 2026-03-28 11:13:16 -07:00
parent be86ed8799
commit 0ffef39853

View file

@ -701,26 +701,25 @@ class WatchlistScanner:
logger.info(f"Using {provider} provider for {watchlist_artist.artist_name} (ID: {artist_id})") logger.info(f"Using {provider} provider for {watchlist_artist.artist_name} (ID: {artist_id})")
# Update artist image (cached for performance) # Update artist image if missing or on every scan to keep fresh
try: try:
image_url = None
artist_data = client.get_artist(artist_id) artist_data = client.get_artist(artist_id)
if artist_data and 'images' in artist_data and artist_data['images']: if artist_data:
# Get medium-sized image (usually the second one, or first if only one) if 'images' in artist_data and artist_data['images']:
image_url = None # Spotify/Deezer format: array of {url, height, width}
if len(artist_data['images']) > 1: image_url = artist_data['images'][1]['url'] if len(artist_data['images']) > 1 else artist_data['images'][0]['url']
image_url = artist_data['images'][1]['url'] elif artist_data.get('image_url'):
else: # Direct image_url format (iTunes/some providers)
image_url = artist_data['images'][0]['url'] image_url = artist_data['image_url']
# Update in database (use spotify_artist_id as the key for consistency) if image_url:
if image_url: db_artist_id = watchlist_artist.spotify_artist_id or watchlist_artist.itunes_artist_id or watchlist_artist.deezer_artist_id or artist_id
db_artist_id = watchlist_artist.spotify_artist_id or artist_id self.database.update_watchlist_artist_image(db_artist_id, image_url)
self.database.update_watchlist_artist_image(db_artist_id, image_url) if not watchlist_artist.image_url:
logger.info(f"Updated artist image for {watchlist_artist.artist_name}") logger.info(f"Backfilled artist image for {watchlist_artist.artist_name}")
else:
logger.warning(f"No image URL found for {watchlist_artist.artist_name}")
else: else:
logger.warning(f"No images in {provider} data for {watchlist_artist.artist_name}") logger.debug(f"No image available for {watchlist_artist.artist_name} from {provider}")
except Exception as img_error: except Exception as img_error:
logger.warning(f"Could not update artist image for {watchlist_artist.artist_name}: {img_error}") logger.warning(f"Could not update artist image for {watchlist_artist.artist_name}: {img_error}")