From 883b43b015b8668abbdb9e7c42726b0a56361ec4 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Sun, 15 Feb 2026 10:48:58 -0800 Subject: [PATCH] fix issue where wishlist would not delete entire album. Also fixed issue where a warning was displayed. --- core/wishlist_service.py | 2 +- database/music_database.py | 7 ++++++- web_server.py | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/wishlist_service.py b/core/wishlist_service.py index 27f1afe0..9ec06c91 100644 --- a/core/wishlist_service.py +++ b/core/wishlist_service.py @@ -271,7 +271,7 @@ class WishlistService: spotify_data = track['spotify_data'] recent_failures.append({ 'name': spotify_data.get('name', 'Unknown Track'), - 'artist': spotify_data.get('artists', [{}])[0].get('name', 'Unknown Artist'), + 'artist': (spotify_data.get('artists', [{}])[0].get('name', 'Unknown Artist') if isinstance(spotify_data.get('artists', [{}])[0], dict) else spotify_data.get('artists', ['Unknown Artist'])[0]) if spotify_data.get('artists') else 'Unknown Artist', 'failure_reason': track['failure_reason'], 'retry_count': track['retry_count'], 'date_added': track['date_added'] diff --git a/database/music_database.py b/database/music_database.py index 560bad6d..59624b31 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -3095,7 +3095,12 @@ class MusicDatabase: track_data = json.loads(track['spotify_data']) track_name = track_data.get('name', '').lower() artists = track_data.get('artists', []) - artist_name = artists[0].get('name', '').lower() if artists else 'unknown' + if artists and isinstance(artists[0], dict): + artist_name = artists[0].get('name', '').lower() + elif artists: + artist_name = str(artists[0]).lower() + else: + artist_name = 'unknown' key = (track_name, artist_name) diff --git a/web_server.py b/web_server.py index e46b3385..d1be25c9 100644 --- a/web_server.py +++ b/web_server.py @@ -11130,7 +11130,13 @@ def remove_album_from_wishlist(): # Create custom ID matching frontend logic exactly # album_data is guaranteed to be a dict from above check album_name = album_data.get('name', 'Unknown Album') - artist_name = spotify_data.get('artists', [{}])[0].get('name', 'Unknown Artist') if spotify_data.get('artists') else 'Unknown Artist' + artists = spotify_data.get('artists', []) + if artists and isinstance(artists[0], dict): + artist_name = artists[0].get('name', 'Unknown Artist') + elif artists and isinstance(artists[0], str): + artist_name = artists[0] + else: + artist_name = 'Unknown Artist' custom_id = f"{album_name}_{artist_name}" # Match frontend regex exactly: # 1. Remove all special chars except spaces, underscores, hyphens: /[^a-zA-Z0-9\s_-]/g