fix: always write English genre for all download paths
1. JP genre mapping table in metadata.js — when only JP iTunes has the song (niche Japanese artists), map localized JP genre names (アニメ, ポップ, etc.) to English equivalents so files never get Japanese characters in genre tag. 2. Spotify playlist import (alreadyEnriched path) — was skipping iTunes lookup entirely, leaving genre empty. Now does a lightweight genre-only lookup. 3. Single track download with Spotify album — was skipping iTunes when album already known from Spotify. Now also fetches genre from iTunes when missing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ae439bfd2
commit
78024181f0
2 files changed
+27
-5
No files matched your search
@@ -416,14 +416,19 @@ app.post('/api/download', async (req, res) => {
|
||||
artworkUrl: spArt, explicit: sp.trackExplicitness === 'explicit' || !!explicit,
|
||||
durationMs: sp.durationMs || undefined,
|
||||
};
|
||||
const searchArtist = artist.split(',')[0].trim();
|
||||
if (!meta.album) {
|
||||
const searchArtist = artist.split(',')[0].trim();
|
||||
log(jobId, '📋 Suche Album-Metadaten von iTunes…');
|
||||
const extra = await lookupItunesTrackMeta(searchArtist, title);
|
||||
if (extra.album) log(jobId, `📋 Album: "${extra.album}" (${extra.year || '?'})`);
|
||||
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) {
|
||||
const genreMeta = await lookupItunesTrackMeta(searchArtist, title).catch(() => ({}));
|
||||
if (genreMeta.genre) { meta.genre = genreMeta.genre; log(jobId, `📋 Genre: "${genreMeta.genre}"`); }
|
||||
}
|
||||
}
|
||||
const finalArtist = meta.itunesArtistName || artist;
|
||||
const result = await downloadTrack({ jobId, artist: finalArtist, rawArtist: artist, title, ...meta, sourceUrl: sourceUrl || sp.sourceUrl || undefined });
|
||||
@@ -492,11 +497,14 @@ app.post('/api/download', async (req, res) => {
|
||||
// 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);
|
||||
const searchArtist = trackArtist.split(',')[0].trim();
|
||||
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
|
||||
const genreMeta = await lookupItunesTrackMeta(searchArtist, trackTitle).catch(() => ({}));
|
||||
itunes = { genre: genreMeta.genre };
|
||||
} else {
|
||||
const searchArtist = trackArtist.split(',')[0].trim();
|
||||
log(jobId, `📋 iTunes: "${trackArtist} – ${trackTitle}"`);
|
||||
itunes = await lookupItunesTrackMeta(searchArtist, trackTitle);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user