fix: handle iTunes rate-limit empty responses, reduce Spotify artwork concurrency
- itunesSearch: use r.text() + JSON.parse so empty body (rate-limit) returns [] instead of throwing - reduce Spotify artwork batch size 8→4 to avoid hammering iTunes and affecting global search Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
a61436669e
commit
2b6870583b
2 files changed
+7
-4
No files matched your search
+6
-3
@@ -43,9 +43,12 @@ export async function ndAuth() {
|
||||
const ITUNES = 'https://itunes.apple.com';
|
||||
|
||||
export async function itunesSearch(query, entity='musicTrack', limit=25) {
|
||||
const r = await fetch(`${ITUNES}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=us&explicit=Yes`);
|
||||
const d = await r.json();
|
||||
return d.results || [];
|
||||
try {
|
||||
const r = await fetch(`${ITUNES}/search?term=${encodeURIComponent(query)}&media=music&entity=${entity}&limit=${limit}&country=us&explicit=Yes`);
|
||||
const text = await r.text();
|
||||
if (!text) return [];
|
||||
return JSON.parse(text).results || [];
|
||||
} catch { return []; }
|
||||
}
|
||||
|
||||
export async function itunesLookupAlbum(collectionId) {
|
||||
|
||||
Reference in new issue
Block a user