From 7d18d4ecb22060ddc5ea9cce61d3bf24e11e756d Mon Sep 17 00:00:00 2001 From: Antti Kettunen Date: Fri, 17 Apr 2026 10:01:51 +0300 Subject: [PATCH] Clarify comments --- core/watchlist_scanner.py | 4 ++-- database/music_database.py | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/watchlist_scanner.py b/core/watchlist_scanner.py index c5726810..2cdc9a03 100644 --- a/core/watchlist_scanner.py +++ b/core/watchlist_scanner.py @@ -859,7 +859,7 @@ class WatchlistScanner: Returns the first provider that can actually return albums. Args: - watchlist_artist: WatchlistArtist object (has both spotify and itunes IDs) + watchlist_artist: WatchlistArtist object (has provider IDs when available) last_scan_timestamp: Only return releases after this date (for incremental scans) Returns: @@ -2398,7 +2398,7 @@ class WatchlistScanner: Populate discovery pool with tracks from top similar artists. Called after watchlist scan completes. - Supports both Spotify and iTunes sources - populates for whichever is available. + Supports Spotify, iTunes, and Deezer sources - populates for whichever is available. - Checks if pool was updated in last 24 hours (prevents over-polling) - Includes albums, singles, and EPs for comprehensive coverage - Appends to existing pool instead of replacing it diff --git a/database/music_database.py b/database/music_database.py index 61d0a0f4..4521605e 100644 --- a/database/music_database.py +++ b/database/music_database.py @@ -912,7 +912,7 @@ class MusicDatabase: """Add tables for discovery feature: similar artists, discovery pool, and recent releases""" try: # Similar Artists table - stores similar artists for each watchlist artist - # Supports both Spotify and iTunes IDs for dual-source discovery + # Supports Spotify plus fallback provider IDs for discovery cursor.execute(""" CREATE TABLE IF NOT EXISTS similar_artists ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -928,7 +928,7 @@ class MusicDatabase: """) # Discovery Pool table - rotating pool of 1000-2000 tracks for recommendations - # Supports both Spotify and iTunes sources for dual-source discovery + # Supports Spotify, iTunes, and Deezer sources for discovery cursor.execute(""" CREATE TABLE IF NOT EXISTS discovery_pool ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -954,7 +954,7 @@ class MusicDatabase: """) # Recent Releases table - tracks new releases from watchlist artists - # Supports both Spotify and iTunes sources for dual-source discovery + # Supports Spotify, iTunes, and Deezer sources for discovery cursor.execute(""" CREATE TABLE IF NOT EXISTS recent_releases ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -973,7 +973,7 @@ class MusicDatabase: """) # Discovery Recent Albums cache - for discover page recent releases section - # Supports both Spotify and iTunes sources for dual-source discovery + # Supports Spotify, iTunes, and Deezer sources for discovery cursor.execute(""" CREATE TABLE IF NOT EXISTS discovery_recent_albums ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -7136,7 +7136,7 @@ class MusicDatabase: return 0 def update_watchlist_artist_image(self, artist_id: str, image_url: str) -> bool: - """Update the image URL for a watchlist artist (checks both Spotify and iTunes IDs)""" + """Update the image URL for a watchlist artist (checks linked provider IDs)""" try: with self._get_connection() as conn: cursor = conn.cursor() @@ -7356,13 +7356,13 @@ class MusicDatabase: logger.error(f"Error getting similar artists: {e}") return [] - def get_similar_artists_missing_itunes_ids(self, source_artist_id: str, profile_id: int = 1) -> List[SimilarArtist]: - """Get similar artists for a source that are missing iTunes IDs (for backfill)""" - return self.get_similar_artists_missing_fallback_ids(source_artist_id, 'itunes', profile_id) - def get_similar_artists_missing_fallback_ids(self, source_artist_id: str, fallback_source: str = 'itunes', profile_id: int = 1) -> List[SimilarArtist]: - """Get similar artists missing IDs for the given fallback source (for backfill)""" + """Get similar artists missing fallback-provider IDs for backfill.""" try: + if fallback_source not in {'itunes', 'deezer'}: + logger.error("Unsupported similar-artist fallback source: %s", fallback_source) + return [] + col = 'similar_artist_deezer_id' if fallback_source == 'deezer' else 'similar_artist_itunes_id' with self._get_connection() as conn: cursor = conn.cursor() @@ -7606,7 +7606,7 @@ class MusicDatabase: logger.error(f"Error marking artists as featured: {e}") def add_to_discovery_pool(self, track_data: Dict[str, Any], source: str = 'spotify', profile_id: int = 1) -> bool: - """Add a track to the discovery pool (supports both Spotify and iTunes sources)""" + """Add a track to the discovery pool (supports Spotify, iTunes, and Deezer sources)""" try: with self._get_connection() as conn: cursor = conn.cursor() @@ -7701,7 +7701,7 @@ class MusicDatabase: logger.error(f"Error rotating discovery pool: {e}") def get_discovery_pool_tracks(self, limit: int = 100, new_releases_only: bool = False, source: Optional[str] = None, profile_id: int = 1) -> List[DiscoveryTrack]: - """Get tracks from discovery pool, optionally filtered by source ('spotify' or 'itunes')""" + """Get tracks from discovery pool, optionally filtered by source ('spotify', 'itunes', or 'deezer')""" try: with self._get_connection() as conn: cursor = conn.cursor() @@ -7759,7 +7759,7 @@ class MusicDatabase: return [] def cache_discovery_recent_album(self, album_data: Dict[str, Any], source: str = 'spotify', profile_id: int = 1) -> bool: - """Cache a recent album for the discover page (supports both Spotify and iTunes sources)""" + """Cache a recent album for the discover page (supports Spotify, iTunes, and Deezer sources)""" try: with self._get_connection() as conn: cursor = conn.cursor()