Add defensive album data repair in wishlist add_to_wishlist

If album info is missing, not a dict, or named "Unknown Album",
it gets repaired using the track name as fallback instead of
storing junk display data.
This commit is contained in:
Broque Thomas 2026-03-18 17:57:33 -07:00
parent 0dd0d50837
commit 5489af2647

View file

@ -5272,6 +5272,15 @@ class MusicDatabase:
else:
artist_name = 'Unknown Artist'
# Ensure album is a proper dict — repair if needed so display doesn't break
album = spotify_track_data.get('album')
if not album or not isinstance(album, dict):
spotify_track_data['album'] = {'name': track_name, 'images': []}
logger.info(f"Wishlist add: no album info for '{track_name}', using track name as fallback")
elif not album.get('name') or album.get('name') in ('Unknown Album', ''):
album['name'] = track_name
logger.info(f"Wishlist add: missing album name for '{track_name}', using track name as fallback")
# Check for duplicates by track name + artist (not just Spotify ID)
# This prevents adding the same track multiple times with different IDs or edge cases
cursor.execute("""