fix: correct artist names and prevent wrong song downloads for Japanese tracks
- spotify.js: stop overwriting trackName with iTunes English title — yt-dlp must search with original Japanese title to find the right song (was downloading English covers e.g. Ghost In A Flower instead of 幽霊花) - metadata.js: add title-only fallback in lookupItunesTrackMeta so tracks are found even when kuromoji gives wrong artist romanization (e.g. Terui Jun Sei vs iTunes Yoshimasa Terui); also return itunesArtistName - novasonic-server.js: use itunesArtistName from iTunes lookup as the stored artist when available (single-track and playlist download paths) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
392da7e021
commit
c7bebd5691
3 files changed
+22
-18
No files matched your search
+15
-11
@@ -103,21 +103,25 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
const normA = (artist || '').toLowerCase().trim();
|
||||
// Split by space OR comma/semicolon/slash so "VXLLAIN, iGRES" → "vxllain" not "vxllain,"
|
||||
const firstWord = s => (s || '').toLowerCase().split(/[\s,;/]/)[0];
|
||||
const match = results.find(t =>
|
||||
// Prefer strict match (title + first-word artist), fall back to title-only.
|
||||
// Title-only fallback handles cases where kuromoji gave a wrong artist romanization
|
||||
// (e.g. "Terui Jun Sei" vs iTunes "Yoshimasa Terui" — different first word).
|
||||
const match = results.find(t =>
|
||||
normalizeTitle(t.trackName) === normT &&
|
||||
firstWord(t.artistName) === firstWord(normA)
|
||||
);
|
||||
) || results.find(t => normalizeTitle(t.trackName) === normT);
|
||||
if (!match) return {};
|
||||
return {
|
||||
album: match.collectionName || '',
|
||||
year: match.releaseDate ? new Date(match.releaseDate).getFullYear() : undefined,
|
||||
trackNum: match.trackNumber || undefined,
|
||||
totalTracks: match.trackCount || undefined,
|
||||
discNum: match.discNumber || undefined,
|
||||
discTotal: match.discCount || undefined,
|
||||
genre: match.primaryGenreName || undefined,
|
||||
artworkUrl: (match.artworkUrl100 || '').replace('100x100bb', '1000x1000bb'),
|
||||
durationMs: match.trackTimeMillis || undefined,
|
||||
album: match.collectionName || '',
|
||||
year: match.releaseDate ? new Date(match.releaseDate).getFullYear() : undefined,
|
||||
trackNum: match.trackNumber || undefined,
|
||||
totalTracks: match.trackCount || undefined,
|
||||
discNum: match.discNumber || undefined,
|
||||
discTotal: match.discCount || undefined,
|
||||
genre: match.primaryGenreName || undefined,
|
||||
artworkUrl: (match.artworkUrl100 || '').replace('100x100bb', '1000x1000bb'),
|
||||
durationMs: match.trackTimeMillis || undefined,
|
||||
itunesArtistName: match.artistName || undefined,
|
||||
};
|
||||
} catch { return {}; }
|
||||
}
|
||||
|
||||
@@ -364,7 +364,8 @@ app.post('/api/download', async (req, res) => {
|
||||
} else {
|
||||
log(jobId, `📋 Album aus Spotify: "${meta.album}"`);
|
||||
}
|
||||
const result = await downloadTrack({ jobId, artist, title, ...meta, sourceUrl: sourceUrl || sp.sourceUrl || undefined });
|
||||
const finalArtist = meta.itunesArtistName || artist;
|
||||
const result = await downloadTrack({ jobId, artist: finalArtist, title, ...meta, sourceUrl: sourceUrl || sp.sourceUrl || undefined });
|
||||
if (result?.skipped) {
|
||||
updateJob(jobId, { status: 'done', progress: 100, message: 'Bereits vorhanden – übersprungen', skipped: true });
|
||||
} else {
|
||||
@@ -438,10 +439,11 @@ app.post('/api/download', async (req, res) => {
|
||||
log(jobId, `📋 iTunes: "${trackArtist} – ${trackTitle}"`);
|
||||
itunes = await lookupItunesTrackMeta(searchArtist, trackTitle);
|
||||
}
|
||||
const resolvedArtist = itunes.itunesArtistName || trackArtist;
|
||||
return downloadTrack({
|
||||
jobId,
|
||||
artist: trackArtist,
|
||||
albumArtist: trackArtist,
|
||||
artist: resolvedArtist,
|
||||
albumArtist: resolvedArtist,
|
||||
title: trackTitle,
|
||||
album: itunes.album || track.collectionName || track.album || '',
|
||||
year: itunes.year || (track.releaseDate ? new Date(track.releaseDate).getFullYear() : undefined) || track.year,
|
||||
|
||||
Reference in new issue
Block a user