From a387814deb654032794d36cb8e618a384cf32ec6 Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Fri, 5 Jun 2026 14:00:50 -0700 Subject: [PATCH] #798: Spotify Free as a rate-limit bridge for connected users (hybrid) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Spotify Free is enabled, it now also bridges an official rate-limit ban for authenticated users instead of stalling — search already did this (the gate opens on no-auth OR rate-limit); this extends it to the enrichment worker. - spotify_worker: the rate-limit guard now sleeps only when free CAN'T cover (is_spotify_metadata_available() is False). Purely additive — with Spotify Free off, that's False during a ban and the worker sleeps exactly as before. Verified: toggle OFF + rate-limited -> sleeps (original); toggle ON -> bridges. - Reframed the Settings toggle so connected users know it also covers rate-limits ("Use Spotify Free when Spotify is unavailable or rate-limited"). The official auth path is untouched; free never runs while authed Spotify works normally. --- core/spotify_worker.py | 10 ++++++++-- webui/index.html | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/spotify_worker.py b/core/spotify_worker.py index 844b9eb3..f8e8cc3a 100644 --- a/core/spotify_worker.py +++ b/core/spotify_worker.py @@ -186,8 +186,14 @@ class SpotifyWorker: interruptible_sleep(self._stop_event, 1) continue - # Rate limit guard — if globally rate limited, sleep until ban expires - if self.client.is_rate_limited(): + # Rate limit guard — if globally rate limited, sleep until ban + # expires. EXCEPT: when Spotify Free is available it bridges the + # ban (is_spotify_metadata_available() is True via the no-creds + # source, and the client routes there), so we keep enriching + # instead of stalling. Purely additive: with Spotify Free off, + # is_spotify_metadata_available() is False during a ban and this + # sleeps exactly as before. + if self.client.is_rate_limited() and not self.client.is_spotify_metadata_available(): info = self.client.get_rate_limit_info() remaining = info['remaining_seconds'] if info else 60 logger.debug(f"Spotify globally rate limited, sleeping {remaining}s...") diff --git a/webui/index.html b/webui/index.html index d42a28fc..d5920273 100644 --- a/webui/index.html +++ b/webui/index.html @@ -3847,9 +3847,9 @@
-
Fetch Spotify metadata without API credentials, for when you can't or don't want to connect Spotify. Unofficial & best-effort (it can break if Spotify changes), and it can't search albums by name or access your library — only used when Spotify isn't authenticated.
+
Fetches Spotify metadata without API credentials. Works two ways: as a full Spotify source if you haven't connected your account, and as a bridge that keeps search & enrichment going when your connected Spotify hits a rate-limit. Unofficial & best-effort (can break if Spotify changes); it can't search albums by name or access your library, and never runs while your authenticated Spotify is working normally.
Choose the primary source for artist, album, and track metadata. Spotify needs an active session — or enable Spotify Free above. Discogs requires a personal token. MusicBrainz is always available but rate-limited to 1 req/sec.