diff --git a/core/watchlist_scanner.py b/core/watchlist_scanner.py index c4b778d6..0a6512c2 100644 --- a/core/watchlist_scanner.py +++ b/core/watchlist_scanner.py @@ -763,7 +763,7 @@ class WatchlistScanner: # Return all albums if no cutoff (lookback_period = 'all') return albums - + except Exception as e: logger.error(f"Error getting discography for artist {spotify_artist_id}: {e}") return None diff --git a/database/music_database.py b/database/music_database.py index 618b1768..4fcda85a 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -3544,13 +3544,19 @@ class MusicDatabase: return 0 def clear_wishlist(self) -> bool: - """Clear all tracks from the wishlist""" + """Clear all tracks from the wishlist and reset scan timestamps so next scan re-discovers everything""" try: with self._get_connection() as conn: cursor = conn.cursor() cursor.execute("DELETE FROM wishlist_tracks") + cleared_count = cursor.rowcount + # Reset last_scan_timestamp on all watchlist artists so the next scan + # uses the lookback period setting (e.g. "entire discography") instead + # of only finding albums released after the old scan date + cursor.execute("UPDATE watchlist_artists SET last_scan_timestamp = NULL") + reset_count = cursor.rowcount conn.commit() - logger.info(f"Cleared {cursor.rowcount} tracks from wishlist") + logger.info(f"Cleared {cleared_count} tracks from wishlist, reset scan timestamps on {reset_count} artists") return True except Exception as e: logger.error(f"Error clearing wishlist: {e}") diff --git a/web_server.py b/web_server.py index f0199731..a7f30f88 100644 --- a/web_server.py +++ b/web_server.py @@ -11623,9 +11623,15 @@ def set_discovery_lookback_period(): INSERT OR REPLACE INTO metadata (key, value, updated_at) VALUES ('discovery_lookback_period', ?, CURRENT_TIMESTAMP) """, (period,)) + + # When expanding the lookback window (especially to "entire disco"), + # reset scan timestamps so the next scan re-discovers older releases + # that were filtered out under the previous narrower setting + cursor.execute("UPDATE watchlist_artists SET last_scan_timestamp = NULL") + reset_count = cursor.rowcount conn.commit() - print(f"✅ Discovery lookback period set to: {period}") + print(f"✅ Discovery lookback period set to: {period}, reset scan timestamps on {reset_count} artists") return jsonify({"success": True, "period": period}) except Exception as e: @@ -20153,7 +20159,7 @@ def start_watchlist_scan(): # Get artist discography using provider-aware method albums = scanner.get_artist_discography_for_watchlist(artist, artist.last_scan_timestamp) - + if albums is None: scan_results.append(type('ScanResult', (), { 'artist_name': artist.artist_name,