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
+17
-3
@@ -88,6 +88,19 @@ function normalizeTitle(s) {
|
||||
.trim();
|
||||
}
|
||||
|
||||
// iTunes JP store returns localized genre names — map them to English equivalents
|
||||
const JP_GENRE_MAP = {
|
||||
'アニメ': 'Anime', 'イージーリスニング': 'Easy Listening', 'ポップ': 'Pop',
|
||||
'J-Pop': 'J-Pop', 'ロック': 'Rock', 'クラシック': 'Classical', 'ジャズ': 'Jazz',
|
||||
'エレクトロニック': 'Electronic', 'R&B/ソウル': 'R&B/Soul', 'ヒップホップ/ラップ': 'Hip-Hop/Rap',
|
||||
'オルタナティブ': 'Alternative', 'サウンドトラック': 'Soundtrack', 'ボーカル': 'Vocal',
|
||||
'インストゥルメンタル': 'Instrumental', 'ワールド': 'World', 'フォーク': 'Folk',
|
||||
'カントリー': 'Country', 'レゲエ': 'Reggae', 'ソウル': 'Soul', 'ブルース': 'Blues',
|
||||
'メタル': 'Metal', 'パンク': 'Punk', 'ダンス': 'Dance', 'コメディ': 'Comedy',
|
||||
'スピーチ': 'Speech', 'キッズ/ファミリー': 'Kids/Family',
|
||||
};
|
||||
function toEnglishGenre(g) { return JP_GENRE_MAP[g] || g; }
|
||||
|
||||
// iTunes track lookup — fills in album, year, trackNum, totalTracks, genre when missing
|
||||
async function lookupItunesTrackMeta(artist, title) {
|
||||
try {
|
||||
@@ -118,8 +131,9 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
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;
|
||||
// JP genre names are localized (e.g. イージーリスニング); prefer US genre, map JP→EN as fallback
|
||||
const rawGenre = (usMatch || match).primaryGenreName;
|
||||
const genre = rawGenre ? toEnglishGenre(rawGenre) : undefined;
|
||||
return {
|
||||
album: match.collectionName || '',
|
||||
year: match.releaseDate ? new Date(match.releaseDate).getFullYear() : undefined,
|
||||
@@ -127,7 +141,7 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
totalTracks: match.trackCount || undefined,
|
||||
discNum: match.discNumber || undefined,
|
||||
discTotal: match.discCount || undefined,
|
||||
genre: genre || undefined,
|
||||
genre: genre,
|
||||
artworkUrl: (match.artworkUrl100 || '').replace('100x100bb', '1000x1000bb'),
|
||||
durationMs: match.trackTimeMillis || undefined,
|
||||
itunesArtistName: match.artistName || undefined,
|
||||
|
||||
Reference in new issue
Block a user