fix: improve Spotify importer metadata — copy iTunes durationMs, skip redundant backend lookup when frontend already enriched track
This commit is contained in:
1 parent
e78df7bdb9
commit
11dec04fea
2 files changed
+13
-3
No files matched your search
@@ -276,9 +276,18 @@ app.post('/api/download', async (req, res) => {
|
||||
const batchResults = await Promise.allSettled(batch.map(async track => {
|
||||
const trackTitle = track.trackName || '';
|
||||
const trackArtist = track.artistName || artist || '';
|
||||
const searchArtist = trackArtist.split(',')[0].trim();
|
||||
log(jobId, `📋 iTunes: "${trackArtist} – ${trackTitle}"`);
|
||||
const itunes = await lookupItunesTrackMeta(searchArtist, trackTitle);
|
||||
// If the frontend already enriched this track with iTunes data (collectionName +
|
||||
// trackNumber + durationMs all present), skip the re-lookup to avoid a different
|
||||
// iTunes result overriding the already-correct enriched metadata.
|
||||
const alreadyEnriched = !!(track.collectionName && track.trackNumber && track.durationMs);
|
||||
let itunes = {};
|
||||
if (alreadyEnriched) {
|
||||
log(jobId, `📋 Frontend-Metadaten: "${trackArtist} – ${trackTitle}" (${track.collectionName})`);
|
||||
} else {
|
||||
const searchArtist = trackArtist.split(',')[0].trim();
|
||||
log(jobId, `📋 iTunes: "${trackArtist} – ${trackTitle}"`);
|
||||
itunes = await lookupItunesTrackMeta(searchArtist, trackTitle);
|
||||
}
|
||||
return downloadTrack({
|
||||
jobId,
|
||||
artist: trackArtist,
|
||||
|
||||
Reference in new issue
Block a user