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
+6
-4
@@ -135,10 +135,12 @@ function _itunesBase() {
|
||||
|
||||
export async function itunesSearch(query, entity='musicTrack', limit=25) {
|
||||
try {
|
||||
const r = await fetch(`${_itunesBase()}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=jp&explicit=Yes`);
|
||||
const text = await r.text();
|
||||
if (!text) return [];
|
||||
return JSON.parse(text).results || [];
|
||||
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 || [];
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user