From b9d3c4051e52faec5377f4bcf775a6fd0613966a Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Tue, 17 Mar 2026 08:12:34 -0700 Subject: [PATCH] Fix Unknown Album in wishlist: album name lost when raw Spotify data missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: discovery searches return (Track, raw_data, confidence) but raw_data can be None (Strategy 4 extended search) or have mismatched index. When raw_data is None, album_obj becomes {} — an empty dict that passes normalization unchanged, so album name is never populated. Fix: after extracting album_obj from raw_data, fall back to track_obj.album (always populated from the SpotifyTrack dataclass) when album_obj has no name. Applied to all 3 discovery paths (Deezer, Tidal, Spotify Public). Also handle both string and dict album formats in wishlist UI rendering. --- web_server.py | 21 ++++++++++++++++++--- webui/static/script.js | 3 ++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/web_server.py b/web_server.py index 2ad69cbf..04b8ea66 100644 --- a/web_server.py +++ b/web_server.py @@ -25743,8 +25743,13 @@ def _run_tidal_discovery_worker(playlist_id): # Spotify: Function returns (Track, raw_data, confidence) track_obj, raw_track_data, match_confidence = track_result album_obj = raw_track_data.get('album', {}) if raw_track_data else {} + # Ensure album has a name — fall back to track_obj.album if raw_data was missing + if isinstance(album_obj, dict) and not album_obj.get('name') and track_obj.album: + album_obj['name'] = track_obj.album + elif not album_obj and track_obj.album: + album_obj = {'name': track_obj.album} # Extract image URL from album data or track object - _album_images = album_obj.get('images', []) + _album_images = album_obj.get('images', []) if isinstance(album_obj, dict) else [] _image_url = _album_images[0].get('url', '') if _album_images else (getattr(track_obj, 'image_url', '') or '') match_data = { @@ -26700,8 +26705,13 @@ def _run_deezer_discovery_worker(playlist_id): # Spotify: Function returns (Track, raw_data, confidence) track_obj, raw_track_data, match_confidence = track_result album_obj = raw_track_data.get('album', {}) if raw_track_data else {} + # Ensure album has a name — fall back to track_obj.album if raw_data was missing + if isinstance(album_obj, dict) and not album_obj.get('name') and track_obj.album: + album_obj['name'] = track_obj.album + elif not album_obj and track_obj.album: + album_obj = {'name': track_obj.album} # Extract image URL from album data or track object - _album_images = album_obj.get('images', []) + _album_images = album_obj.get('images', []) if isinstance(album_obj, dict) else [] _image_url = _album_images[0].get('url', '') if _album_images else (getattr(track_obj, 'image_url', '') or '') match_data = { @@ -27519,8 +27529,13 @@ def _run_spotify_public_discovery_worker(url_hash): # Spotify: Function returns (Track, raw_data, confidence) track_obj, raw_track_data, match_confidence = track_result album_obj = raw_track_data.get('album', {}) if raw_track_data else {} + # Ensure album has a name — fall back to track_obj.album if raw_data was missing + if isinstance(album_obj, dict) and not album_obj.get('name') and track_obj.album: + album_obj['name'] = track_obj.album + elif not album_obj and track_obj.album: + album_obj = {'name': track_obj.album} # Extract image URL from album data or track object - _album_images = album_obj.get('images', []) + _album_images = album_obj.get('images', []) if isinstance(album_obj, dict) else [] _image_url = _album_images[0].get('url', '') if _album_images else (getattr(track_obj, 'image_url', '') or '') match_data = { diff --git a/webui/static/script.js b/webui/static/script.js index 4cd3a3ba..7e9e75fc 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -11076,7 +11076,8 @@ async function selectWishlistCategory(category) { } } - const albumName = spotifyData?.album?.name || 'Unknown Album'; + const rawAlbum = spotifyData?.album; + const albumName = (typeof rawAlbum === 'string' ? rawAlbum : rawAlbum?.name) || 'Unknown Album'; // Handle both object format {name: '...'} and sanitized string format let artistName = 'Unknown Artist';