fix: use US iTunes genre to avoid Japanese-localized genre names
JP store returns localized genres (e.g. イージーリスニング instead of Easy Listening). Fetch JP and US in parallel, use JP match for title/album/artwork but always take genre from US result so genre is always in English/Western characters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
67f4be272a
commit
760d8d5e1f
1 file changed
+7
-8
@@ -112,15 +112,14 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
);
|
||||
const titleOnlyMatch = results => results.find(t => normalizeTitle(t.trackName) === normT);
|
||||
|
||||
// Strategy: JP strict → US strict → US title-only (never JP title-only to avoid
|
||||
// false positives where JP returns a different Japanese song with the same English title)
|
||||
const jpResults = await fetchItunes('jp');
|
||||
// Fetch both in parallel — JP for correct Japanese titles/artwork, US for English genre names
|
||||
const [jpResults, usResults] = await Promise.all([fetchItunes('jp'), fetchItunes('us')]);
|
||||
let match = strictMatch(jpResults);
|
||||
if (!match) {
|
||||
const usResults = await fetchItunes('us');
|
||||
match = strictMatch(usResults) || titleOnlyMatch(usResults);
|
||||
}
|
||||
let usMatch = strictMatch(usResults) || titleOnlyMatch(usResults);
|
||||
if (!match) match = usMatch;
|
||||
if (!match) return {};
|
||||
// JP genre names are localized (e.g. イージーリスニング); always prefer US genre
|
||||
const genre = (usMatch || match).primaryGenreName;
|
||||
return {
|
||||
album: match.collectionName || '',
|
||||
year: match.releaseDate ? new Date(match.releaseDate).getFullYear() : undefined,
|
||||
@@ -128,7 +127,7 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
totalTracks: match.trackCount || undefined,
|
||||
discNum: match.discNumber || undefined,
|
||||
discTotal: match.discCount || undefined,
|
||||
genre: match.primaryGenreName || undefined,
|
||||
genre: genre || undefined,
|
||||
artworkUrl: (match.artworkUrl100 || '').replace('100x100bb', '1000x1000bb'),
|
||||
durationMs: match.trackTimeMillis || undefined,
|
||||
itunesArtistName: match.artistName || undefined,
|
||||
|
||||
Reference in new issue
Block a user