fix: also write totalTracks, discNum, discTotal for Spotify imports
Spotify enrichment only copies album/trackNum/duration from iTunes. Now also fetch totalTracks, discNum, discTotal from iTunes for: - alreadyEnriched playlist tracks - single track downloads where album came from Spotify Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
78024181f0
commit
4f83055edd
1 file changed
+13
-5
@@ -424,10 +424,13 @@ app.post('/api/download', async (req, res) => {
|
||||
meta = { ...meta, ...extra, artworkUrl: spArt || extra.artworkUrl || '', genre: meta.genre || extra.genre || undefined };
|
||||
} else {
|
||||
log(jobId, `📋 Album aus Spotify: "${meta.album}"`);
|
||||
// Spotify has no per-track genre — still look up genre from iTunes
|
||||
if (!meta.genre) {
|
||||
// Spotify enrichment has no genre, totalTracks, or disc info — fetch from iTunes
|
||||
if (!meta.genre || !meta.totalTracks) {
|
||||
const genreMeta = await lookupItunesTrackMeta(searchArtist, title).catch(() => ({}));
|
||||
if (genreMeta.genre) { meta.genre = genreMeta.genre; log(jobId, `📋 Genre: "${genreMeta.genre}"`); }
|
||||
if (!meta.genre && genreMeta.genre) { meta.genre = genreMeta.genre; log(jobId, `📋 Genre: "${genreMeta.genre}"`); }
|
||||
if (!meta.totalTracks && genreMeta.totalTracks) { meta.totalTracks = genreMeta.totalTracks; }
|
||||
if (!meta.discNum && genreMeta.discNum) { meta.discNum = genreMeta.discNum; }
|
||||
if (!meta.discTotal && genreMeta.discTotal) { meta.discTotal = genreMeta.discTotal; }
|
||||
}
|
||||
}
|
||||
const finalArtist = meta.itunesArtistName || artist;
|
||||
@@ -501,9 +504,14 @@ app.post('/api/download', async (req, res) => {
|
||||
let itunes = {};
|
||||
if (alreadyEnriched) {
|
||||
log(jobId, `📋 Frontend-Metadaten: "${trackArtist} – ${trackTitle}" (${track.collectionName})`);
|
||||
// Still look up genre — frontend enrichment doesn't include it and Spotify has no genre per track
|
||||
// Spotify enrichment copies album/trackNum/duration but not genre/totalTracks/disc — fetch those
|
||||
const genreMeta = await lookupItunesTrackMeta(searchArtist, trackTitle).catch(() => ({}));
|
||||
itunes = { genre: genreMeta.genre };
|
||||
itunes = {
|
||||
genre: genreMeta.genre,
|
||||
totalTracks: genreMeta.totalTracks,
|
||||
discNum: genreMeta.discNum,
|
||||
discTotal: genreMeta.discTotal,
|
||||
};
|
||||
} else {
|
||||
log(jobId, `📋 iTunes: "${trackArtist} – ${trackTitle}"`);
|
||||
itunes = await lookupItunesTrackMeta(searchArtist, trackTitle);
|
||||
|
||||
Reference in new issue
Block a user