fix: use the US iTunes store everywhere for consistent artist naming

Search (web api.js) was JP-first, the download lookups were JP-first, and the Android
client was already US — so the same artist resolved inconsistently: sometimes kanji,
sometimes katakana, sometimes romaji, depending on which path and which store matched.

Switch everything to the US store:
- api.js itunesSearch → country=us (one fetch, matches the Android client)
- metadata.js lookupItunesTrackMeta → US only (drops the JP fetch: consistent names +
  halves the download's iTunes calls, which also eases the rate limit)
- searchItunesAlbumTracks → country=us
- remove the JP-katakana guards in the album/artist download paths (redundant now, and
  they wrongly romanized genuine Japanese artists like 羽岡佳 → "Kei Haneoka")

Titles still come from the source, so a Japanese title the user picked stays Japanese;
only iTunes-derived fields (album_artist, genre, year, artwork) follow the US store.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Opus 4.8 committed 2026-07-29 10:37:07 +02:00
1 parent d98978a6c7
commit 9c8b4775ea
5 files changed
+23 -32

No files matched your search

+4 -6
View File
@@ -275,12 +275,10 @@ function _itunesBase() {
export async function itunesSearch(query, entity='musicTrack', limit=25) {
try {
const base = `${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&explicit=Yes`;
const rJp = await fetch(`${base}&country=jp`);
const jpResults = JSON.parse(await rJp.text()).results || [];
if (jpResults.length) return jpResults;
const rUs = await fetch(`${base}&country=us`);
return JSON.parse(await rUs.text()).results || [];
// US store only — one consistent naming source across search + download (matches the Android
// client, which is already US). A single fetch also halves the iTunes request rate.
const r = await fetch(`${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=us&explicit=Yes`);
return JSON.parse(await r.text()).results || [];
} catch { return []; }
}