From a7ebde8c010f1c0b5897e9f27bc74b3543a75892 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Tue, 31 Mar 2026 21:59:46 -0700 Subject: [PATCH] Add skip_cache param to get_artist_albums for watchlist scans The watchlist auto-scan needs fresh data from Spotify to detect new releases, so it bypasses the cache added in the previous commit. All other callers (UI browsing, completion badges, discography views) continue to benefit from cached results. --- core/spotify_client.py | 21 ++++++++++++--------- web_server.py | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/spotify_client.py b/core/spotify_client.py index 3603e324..0b456fe4 100644 --- a/core/spotify_client.py +++ b/core/spotify_client.py @@ -1305,19 +1305,22 @@ class SpotifyClient: return None @rate_limited - def get_artist_albums(self, artist_id: str, album_type: str = 'album,single', limit: int = 10) -> List[Album]: - """Get albums by artist ID - falls back to iTunes if Spotify not authenticated""" - # Check cache first — keyed by artist_id + album_type + def get_artist_albums(self, artist_id: str, album_type: str = 'album,single', limit: int = 10, skip_cache: bool = False) -> List[Album]: + """Get albums by artist ID - falls back to iTunes if Spotify not authenticated. + Set skip_cache=True for watchlist scans that need fresh data to detect new releases.""" cache = get_metadata_cache() fallback_src = self._fallback_source source = fallback_src if self._is_itunes_id(artist_id) else 'spotify' cache_key = f"{artist_id}_albums_{album_type.replace(',', '_')}" - cached = cache.get_entity(source, 'artist', cache_key) - if cached: - try: - return [Album.from_spotify_album(ad) for ad in cached] - except Exception: - pass # Cache data incompatible, re-fetch + + # Check cache first (unless caller needs fresh data) + if not skip_cache: + cached = cache.get_entity(source, 'artist', cache_key) + if cached: + try: + return [Album.from_spotify_album(ad) for ad in cached] + except Exception: + pass # Cache data incompatible, re-fetch if self.is_spotify_authenticated(): try: diff --git a/web_server.py b/web_server.py index 240bcf9e..10528d66 100644 --- a/web_server.py +++ b/web_server.py @@ -42891,7 +42891,7 @@ def playlist_explorer_build_tree(): # Fetch albums try: - all_albums = active_client.get_artist_albums(artist_id, album_type='album,single', limit=50) + all_albums = active_client.get_artist_albums(artist_id, album_type='album,single', limit=50, skip_cache=True) except Exception as e: return {'success': False, 'error': f'Album fetch failed: {e}'}