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:
HoneyandClaude Sonnet 4.6 committed 2026-04-28 00:54:53 +02:00
1 parent a61436669e
commit 2b6870583b
2 files changed
+6 -3

No files matched your search

+5 -2
View File
@@ -43,9 +43,12 @@ export async function ndAuth() {
const ITUNES = 'https://itunes.apple.com';
export async function itunesSearch(query, entity='musicTrack', limit=25) {
try {
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 || [];
const text = await r.text();
if (!text) return [];
return JSON.parse(text).results || [];
} catch { return []; }
}
export async function itunesLookupAlbum(collectionId) {
+1 -1
View File
@@ -172,7 +172,7 @@ async function _loadSpotifyTrackArtwork(tracks, listEl) {
});
// Enrich each track with iTunes data — same call as global search
const CONC = 8;
const CONC = 4;
for (let i = 0; i < tracks.length; i += CONC) {
const batch = tracks.slice(i, i + CONC);
await Promise.all(batch.map(async (t, bi) => {