Fixed an issue where the wishlist wouldn't open if null value is detected
This commit is contained in:
parent
634e5b6b9c
commit
681d4b3cd2
2 changed files with 23 additions and 7 deletions
|
|
@ -159,7 +159,7 @@ class WishlistService:
|
||||||
'id': spotify_data.get('id'),
|
'id': spotify_data.get('id'),
|
||||||
'name': spotify_data.get('name', 'Unknown Track'),
|
'name': spotify_data.get('name', 'Unknown Track'),
|
||||||
'artists': spotify_data.get('artists', []),
|
'artists': spotify_data.get('artists', []),
|
||||||
'album': spotify_data.get('album', {}),
|
'album': spotify_data.get('album') or {},
|
||||||
'duration_ms': spotify_data.get('duration_ms', 0),
|
'duration_ms': spotify_data.get('duration_ms', 0),
|
||||||
'preview_url': spotify_data.get('preview_url'),
|
'preview_url': spotify_data.get('preview_url'),
|
||||||
'external_urls': spotify_data.get('external_urls', {}),
|
'external_urls': spotify_data.get('external_urls', {}),
|
||||||
|
|
|
||||||
|
|
@ -9301,7 +9301,11 @@ def _process_wishlist_automatically():
|
||||||
except:
|
except:
|
||||||
spotify_data = {}
|
spotify_data = {}
|
||||||
|
|
||||||
album_data = spotify_data.get('album', {})
|
# CRITICAL FIX: Handle case where album is explicitly null in JSON
|
||||||
|
album_data = spotify_data.get('album') or {}
|
||||||
|
# Ensure album_data is a dict (just in case it's a string/other)
|
||||||
|
if not isinstance(album_data, dict):
|
||||||
|
album_data = {}
|
||||||
total_tracks = album_data.get('total_tracks')
|
total_tracks = album_data.get('total_tracks')
|
||||||
album_type = album_data.get('album_type', 'album').lower()
|
album_type = album_data.get('album_type', 'album').lower()
|
||||||
|
|
||||||
|
|
@ -9550,7 +9554,11 @@ def get_wishlist_stats():
|
||||||
import json
|
import json
|
||||||
spotify_data = json.loads(spotify_data)
|
spotify_data = json.loads(spotify_data)
|
||||||
|
|
||||||
album_data = spotify_data.get('album', {})
|
# CRITICAL FIX: Handle case where album is explicitly null in JSON
|
||||||
|
album_data = spotify_data.get('album') or {}
|
||||||
|
# Ensure album_data is a dict (just in case)
|
||||||
|
if not isinstance(album_data, dict):
|
||||||
|
album_data = {}
|
||||||
total_tracks = album_data.get('total_tracks')
|
total_tracks = album_data.get('total_tracks')
|
||||||
album_type = album_data.get('album_type', 'album').lower()
|
album_type = album_data.get('album_type', 'album').lower()
|
||||||
|
|
||||||
|
|
@ -9817,7 +9825,11 @@ def get_wishlist_tracks():
|
||||||
except:
|
except:
|
||||||
spotify_data = {}
|
spotify_data = {}
|
||||||
|
|
||||||
album_data = spotify_data.get('album', {})
|
# CRITICAL FIX: Handle case where album is explicitly null in JSON
|
||||||
|
album_data = spotify_data.get('album') or {}
|
||||||
|
# Ensure album_data is a dict (just in case)
|
||||||
|
if not isinstance(album_data, dict):
|
||||||
|
album_data = {}
|
||||||
total_tracks = album_data.get('total_tracks')
|
total_tracks = album_data.get('total_tracks')
|
||||||
album_type = album_data.get('album_type', 'album').lower()
|
album_type = album_data.get('album_type', 'album').lower()
|
||||||
|
|
||||||
|
|
@ -10234,12 +10246,16 @@ def remove_album_from_wishlist():
|
||||||
except:
|
except:
|
||||||
spotify_data = {}
|
spotify_data = {}
|
||||||
|
|
||||||
# Get album ID - use spotify ID if available, otherwise create custom ID
|
# Get album ID - safely handle null album data
|
||||||
track_album_id = spotify_data.get('album', {}).get('id')
|
album_data = spotify_data.get('album') or {}
|
||||||
|
if not isinstance(album_data, dict):
|
||||||
|
album_data = {}
|
||||||
|
track_album_id = album_data.get('id')
|
||||||
|
|
||||||
if not track_album_id:
|
if not track_album_id:
|
||||||
# Create custom ID matching frontend logic exactly
|
# Create custom ID matching frontend logic exactly
|
||||||
album_name = spotify_data.get('album', {}).get('name', 'Unknown Album')
|
# 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'
|
artist_name = spotify_data.get('artists', [{}])[0].get('name', 'Unknown Artist') if spotify_data.get('artists') else 'Unknown Artist'
|
||||||
custom_id = f"{album_name}_{artist_name}"
|
custom_id = f"{album_name}_{artist_name}"
|
||||||
# Match frontend regex exactly:
|
# Match frontend regex exactly:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue