fix: iTunes JP-first with US fallback; romaji filter in playlist/starred search
This commit is contained in:
1 parent
a9463917e3
commit
3837783225
3 files changed
+17
-9
No files matched your search
@@ -92,13 +92,15 @@ async function lookupItunesTrackMeta(artist, title) {
|
||||
// e.g. "don't rush - slowed" → search "don't rush" so iTunes finds the single
|
||||
const baseTitle = title.replace(/\s*[-–]\s*\S[^-]*$/, '').trim() || title;
|
||||
const searchTitle = baseTitle !== title ? baseTitle : title;
|
||||
const url = `https://itunes.apple.com/search?term=${encodeURIComponent(artist + ' ' + searchTitle)}&media=music&entity=musicTrack&limit=10&country=jp&explicit=Yes`;
|
||||
const results = await new Promise((resolve, reject) => {
|
||||
const fetchItunes = (country) => new Promise((resolve, reject) => {
|
||||
const url = `https://itunes.apple.com/search?term=${encodeURIComponent(artist + ' ' + searchTitle)}&media=music&entity=musicTrack&limit=10&country=${country}&explicit=Yes`;
|
||||
https.get(url, res => {
|
||||
let d = ''; res.on('data', c => d += c);
|
||||
res.on('end', () => { try { resolve(JSON.parse(d).results || []); } catch { reject(new Error('parse')); } });
|
||||
}).on('error', reject);
|
||||
});
|
||||
let results = await fetchItunes('jp');
|
||||
if (!results.length) results = await fetchItunes('us');
|
||||
const normT = normalizeTitle(title);
|
||||
const normA = (artist || '').toLowerCase().trim();
|
||||
// Split by space OR comma/semicolon/slash so "VXLLAIN, iGRES" → "vxllain" not "vxllain,"
|
||||
|
||||
Reference in new issue
Block a user