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
+11
-7
No files matched your search
@@ -103,10 +103,13 @@ 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];
|
||||
// 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 || '',
|
||||
@@ -118,6 +121,7 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
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,
|
||||
|
||||
+1
-3
@@ -295,10 +295,8 @@ async function _loadSpotifyTrackArtwork(tracks, listEl) {
|
||||
if (match.trackExplicitness) t.trackExplicitness = match.trackExplicitness;
|
||||
if (match.previewUrl) t.previewUrl = match.previewUrl;
|
||||
if (match.trackTimeMillis) t.durationMs = match.trackTimeMillis;
|
||||
// Use iTunes canonical English/romaji names — more accurate than Spotify (which may use Japanese)
|
||||
// Use iTunes canonical English/romaji artist name (Spotify may have Japanese or wrong order)
|
||||
if (match.artistName) t.artistName = match.artistName;
|
||||
const JP_RE = /[-ヿ一-鿿]/;
|
||||
if (JP_RE.test(t.trackName) && match.trackName) t.trackName = match.trackName;
|
||||
if (window._spotifyResolved?.tracks?.[idx]) Object.assign(window._spotifyResolved.tracks[idx], t);
|
||||
const url = match.artworkUrl100 || match.artworkUrl60 || '';
|
||||
if (url) _setArt(artEls[idx], url);
|
||||
|
||||
Reference in new issue
Block a user