From 6096049c502299e61f3b0ca18b760988b0a32723 Mon Sep 17 00:00:00 2001 From: Broque Thomas Date: Sun, 25 Jan 2026 17:44:17 -0800 Subject: [PATCH] Fix album tracks added as singles from Library page with iTunes source Library page was using album data from discography listing while Artists page used track.album from API. With iTunes, these could have different track counts, causing different album_type classifications. - Updated handleAddToWishlist to use track.album data like Artists page does - Added album_type copying to owned releases in merge_discography_data --- web_server.py | 1 + webui/static/script.js | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/web_server.py b/web_server.py index b4c5f9f7..aad33251 100644 --- a/web_server.py +++ b/web_server.py @@ -23630,6 +23630,7 @@ def merge_discography_data(owned_releases, spotify_discography): # Add Spotify metadata owned_release['spotify_id'] = spotify_release['spotify_id'] + owned_release['album_type'] = spotify_release.get('album_type', 'album') owned_release['owned'] = True # Calculate track completion using Spotify track count diff --git a/webui/static/script.js b/webui/static/script.js index b3e4a733..081e4480 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -10678,7 +10678,28 @@ async function handleAddToWishlist() { artists: formattedArtists }; + // Use track's album data if available (from API), falling back to modal's album data + // This ensures consistency with how the Artists page handles wishlisting + let trackAlbum = track.album; + let trackAlbumType = albumType || 'album'; + + if (trackAlbum && typeof trackAlbum === 'object') { + // Track has album data from API - use its album_type + trackAlbumType = trackAlbum.album_type || albumType || 'album'; + // Ensure album has required fields + if (!trackAlbum.name) { + trackAlbum.name = album.name; + } + if (!trackAlbum.id) { + trackAlbum.id = album.id; + } + } else { + // Fall back to the album passed to the modal + trackAlbum = album; + } + console.log(`🔄 Adding track with formatted artists:`, formattedTrack.name, formattedTrack.artists); + console.log(`🔄 Using album_type: ${trackAlbumType} (from ${track.album ? 'track.album' : 'modal album'})`); const response = await fetch('/api/add-album-to-wishlist', { method: 'POST', @@ -10688,12 +10709,12 @@ async function handleAddToWishlist() { body: JSON.stringify({ track: formattedTrack, artist: artist, - album: album, + album: trackAlbum, source_type: 'album', source_context: { - album_name: album.name, + album_name: trackAlbum.name, artist_name: artist.name, - album_type: albumType + album_type: trackAlbumType } }) });