Fix Unknown Artist when adding playlist tracks to wishlist
When adding tracks to wishlist from a playlist download modal,
process.artist was undefined (only set for album downloads) and
defaulted to {name: 'Unknown Artist'}. This got stored in
source_info.artist_name and was prioritized over the track's own
artist data during wishlist download post-processing.
Now resolves the artist per-track from the track's own artists array,
falling back to the process-level artist only for album downloads
where it's actually set correctly.
This commit is contained in:
parent
f0ccd197e5
commit
1384b966e8
1 changed files with 17 additions and 5 deletions
|
|
@ -19891,11 +19891,13 @@ async function addModalTracksToWishlist(playlistId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get artist/album context if available (for artist album downloads)
|
// Get album context if available (for artist album downloads)
|
||||||
const artist = process.artist || { name: 'Unknown Artist', id: null };
|
// Artist is resolved per-track below — process.artist is only set for album downloads,
|
||||||
|
// not for playlists, so we must NOT use it as a blanket default.
|
||||||
|
const processArtist = process.artist || null;
|
||||||
const album = process.album || process.playlist || { name: 'Playlist', id: playlistId };
|
const album = process.album || process.playlist || { name: 'Playlist', id: playlistId };
|
||||||
|
|
||||||
console.log(`🔄 Adding ${tracks.length} tracks from "${album.name}" to wishlist`);
|
console.log(`🔄 Adding ${tracks.length} tracks from "${album.name}" to wishlist (process artist: ${processArtist?.name || 'per-track'})`);
|
||||||
|
|
||||||
// Disable the button to prevent double-clicks
|
// Disable the button to prevent double-clicks
|
||||||
const wishlistBtn = document.getElementById(`add-to-wishlist-btn-${playlistId}`);
|
const wishlistBtn = document.getElementById(`add-to-wishlist-btn-${playlistId}`);
|
||||||
|
|
@ -19966,6 +19968,16 @@ async function addModalTracksToWishlist(playlistId) {
|
||||||
trackAlbumType = 'album';
|
trackAlbumType = 'album';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resolve artist per-track: prefer track's own artists over process-level
|
||||||
|
let trackArtist;
|
||||||
|
if (formattedArtists.length > 0 && formattedArtists[0].name && formattedArtists[0].name !== 'Unknown Artist') {
|
||||||
|
trackArtist = formattedArtists[0];
|
||||||
|
} else if (processArtist && processArtist.name) {
|
||||||
|
trackArtist = processArtist;
|
||||||
|
} else {
|
||||||
|
trackArtist = { name: 'Unknown Artist', id: null };
|
||||||
|
}
|
||||||
|
|
||||||
const response = await fetch('/api/add-album-to-wishlist', {
|
const response = await fetch('/api/add-album-to-wishlist', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -19973,12 +19985,12 @@ async function addModalTracksToWishlist(playlistId) {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
track: formattedTrack,
|
track: formattedTrack,
|
||||||
artist: artist,
|
artist: trackArtist,
|
||||||
album: trackAlbum,
|
album: trackAlbum,
|
||||||
source_type: 'album',
|
source_type: 'album',
|
||||||
source_context: {
|
source_context: {
|
||||||
album_name: trackAlbum.name,
|
album_name: trackAlbum.name,
|
||||||
artist_name: artist.name,
|
artist_name: trackArtist.name,
|
||||||
album_type: trackAlbumType
|
album_type: trackAlbumType
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue