From f7e4059f2de5005727ed60ca9718593852809613 Mon Sep 17 00:00:00 2001 From: Honey Date: Sat, 9 May 2026 23:22:56 +0200 Subject: [PATCH] fix: friendly error for Spotify editorial playlist 403 Backend returns {error:'EDITORIAL_PLAYLIST'} on 403 playlist routes. Frontend shows a step-by-step workaround card instead of a red error. Co-Authored-By: Claude Sonnet 4.6 --- backend/novasonic-server.js | 3 +++ src/spotify.js | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/novasonic-server.js b/backend/novasonic-server.js index 337ff17..8371064 100644 --- a/backend/novasonic-server.js +++ b/backend/novasonic-server.js @@ -276,6 +276,9 @@ app.post('/api/spotify/resolve', async (req, res) => { res.status(400).json({ error: `Unbekannter Typ: ${type}` }); } catch(e) { console.error('[spotify/resolve]', e.message); + if (e.message.includes('403') && e.message.includes('/playlists/')) { + return res.status(403).json({ error: 'EDITORIAL_PLAYLIST' }); + } res.status(500).json({ error: e.message }); } }); diff --git a/src/spotify.js b/src/spotify.js index 287e2d0..709d428 100644 --- a/src/spotify.js +++ b/src/spotify.js @@ -66,13 +66,31 @@ export async function resolveSpotifyLink() { }); if (!res.ok) { const err = await res.json().catch(() => ({})); - throw new Error(err.error || `HTTP ${res.status}`); + if (err.error === 'EDITORIAL_PLAYLIST') throw new Error('EDITORIAL_PLAYLIST'); + throw new Error(err.error || err.message || `HTTP ${res.status}`); } const data = await res.json(); window._spotifyResolved = data; if (data.skippedLocal > 0) toast(`${data.skippedLocal} lokale Datei(en) übersprungen (kein Stream verfügbar)`); _renderSpotifyPreview(data); } catch(e) { + if (e.message === 'EDITORIAL_PLAYLIST') { + inner.innerHTML = `
+
💡 Editorial Playlist erkannt
+
+ Spotify hat den API-Zugriff auf eigene kuratierte Playlists + (wie "Today's Top Hits", "Discover Weekly" etc.) für Drittanbieter-Apps gesperrt.

+ Lösung: +
    +
  1. In Spotify die Playlist öffnen
  2. +
  3. Alle Tracks markieren (Strg+A)
  4. +
  5. Rechtsklick → "Zu Playlist hinzufügen" → "Neue Playlist"
  6. +
  7. Diese eigene Kopie hier importieren
  8. +
+
+
`; + return; + } if (e.message.includes('SPOTIFY_CLIENT_ID') || e.message.includes('Credentials fehlen') || e.message.includes('Spotify-Token-Fehler')) {