diff --git a/core/artists/liked_match.py b/core/artists/liked_match.py index 9607e31d..324d8cbc 100644 --- a/core/artists/liked_match.py +++ b/core/artists/liked_match.py @@ -89,20 +89,20 @@ def _match_liked_artists_to_all_sources(database, profile_id: int): search_clients['spotify'] = spotify_client try: search_clients['itunes'] = _get_itunes_client() - except Exception: - pass + except Exception as e: + logger.debug("itunes client init failed: %s", e) try: search_clients['deezer'] = _get_deezer_client() - except Exception: - pass + except Exception as e: + logger.debug("deezer client init failed: %s", e) try: dc = _get_discogs_client() # Only use Discogs if token is configured from config.settings import config_manager as _cm if _cm.get('discogs.token', ''): search_clients['discogs'] = dc - except Exception: - pass + except Exception as e: + logger.debug("discogs client init failed: %s", e) # Reuse watchlist scanner's fuzzy matching logic from core.watchlist_scanner import WatchlistScanner @@ -167,8 +167,8 @@ def _match_liked_artists_to_all_sources(database, profile_id: int): harvested_ids[col] = str(r[col]) if _valid_image(r.get('thumb_url')): best_image = r['thumb_url'] - except Exception: - pass + except Exception as e: + logger.debug("library artist lookup failed: %s", e) # 2. Watchlist artists try: @@ -186,8 +186,8 @@ def _match_liked_artists_to_all_sources(database, profile_id: int): harvested_ids[col] = str(wl[col]) if _valid_image(wl.get('image_url')) and not best_image: best_image = wl['image_url'] - except Exception: - pass + except Exception as e: + logger.debug("watchlist artist lookup failed: %s", e) # 3. Metadata cache (all sources) try: @@ -203,8 +203,8 @@ def _match_liked_artists_to_all_sources(database, profile_id: int): harvested_ids[col] = row['entity_id'] if _valid_image(row['image_url']) and not best_image: best_image = row['image_url'] - except Exception: - pass + except Exception as e: + logger.debug("metadata cache lookup failed: %s", e) # --- API STRATEGIES (search each missing source) --- # Same pattern as watchlist scanner's _backfill_missing_ids @@ -287,8 +287,8 @@ def _backfill_liked_artist_images(database, profile_id: int, search_clients: dic artist_data = sp.sp.artist(r['spotify_artist_id']) if artist_data and artist_data.get('images'): image_url = artist_data['images'][0]['url'] - except Exception: - pass + except Exception as e: + logger.debug("spotify artist image fetch failed: %s", e) # Try Deezer (direct image URL from ID) if not image_url and r.get('deezer_artist_id'): @@ -302,8 +302,8 @@ def _backfill_liked_artist_images(database, profile_id: int, search_clients: dic (image_url, r['id']) ) filled += 1 - except Exception: - pass + except Exception as e: + logger.debug("liked artist image update failed: %s", e) time.sleep(0.3) conn.commit() diff --git a/core/artists/map.py b/core/artists/map.py index 09e880ec..5e6f130a 100644 --- a/core/artists/map.py +++ b/core/artists/map.py @@ -158,8 +158,8 @@ def get_artist_map_data(): if r.get('genres'): try: genres = json.loads(r['genres']) - except Exception: - pass + except Exception as e: + logger.debug("similar node genres parse failed: %s", e) nodes.append({ 'id': idx, 'name': r['similar_artist_name'], @@ -232,8 +232,8 @@ def get_artist_map_data(): if cr['genres']: try: genres = json.loads(cr['genres']) if isinstance(cr['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("backfill cache genres parse failed: %s", e) cache_by_name[cn][source] = { 'id': cr['entity_id'], 'image_url': cr['image_url'] or '', @@ -280,8 +280,8 @@ def get_artist_map_data(): an = _norm(r['artist_name']) if an and an not in _album_art: _album_art[an] = r['image_url'] - except Exception: - pass + except Exception as e: + logger.debug("artist map album-art cache build failed: %s", e) for n in nodes: if not n.get('image_url') or not n['image_url'].startswith('http'): nn = _norm(n['name']) @@ -330,8 +330,8 @@ def get_artist_map_genre_list(): if g and isinstance(g, str): gl = g.lower().strip() genre_counts[gl] = genre_counts.get(gl, 0) + 1 - except Exception: - pass + except Exception as e: + logger.debug("genre count row parse failed: %s", e) # Sort by count descending sorted_genres = sorted(genre_counts.items(), key=lambda x: -x[1]) @@ -404,8 +404,8 @@ def get_artist_map_genres(): if r['genres']: try: genres = json.loads(r['genres']) if isinstance(r['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("cache artist genres parse failed: %s", e) src_map = {'spotify': 'spotify_id', 'itunes': 'itunes_id', 'deezer': 'deezer_id', 'discogs': 'discogs_id'} kwargs = {src_map.get(r['source'], 'spotify_id'): r['entity_id']} _add(r['name'], image_url=r['image_url'], genres=genres, source='cache', popularity=r['popularity'] or 0, **kwargs) @@ -421,8 +421,8 @@ def get_artist_map_genres(): if r['genres']: try: genres = json.loads(r['genres']) if isinstance(r['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("similar artist genres parse failed: %s", e) _add(r['similar_artist_name'], image_url=r['image_url'], genres=genres, spotify_id=r['similar_artist_spotify_id'], itunes_id=r['similar_artist_itunes_id'], deezer_id=r['similar_artist_deezer_id'], source='similar', popularity=r['popularity'] or 0) @@ -445,8 +445,8 @@ def get_artist_map_genres(): if r['genres']: try: genres = json.loads(r['genres']) if isinstance(r['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("library artist genres parse failed: %s", e) img = r['thumb_url'] if r['thumb_url'] and r['thumb_url'].startswith('http') else None _add(r['name'], image_url=img, genres=genres, source='library') @@ -550,8 +550,8 @@ def get_artist_map_genres(): nn = (r['artist_name'] or '').lower().strip() if nn and nn not in _album_art_cache: _album_art_cache[nn] = r['image_url'] - except Exception: - pass + except Exception as e: + logger.debug("genre map cache build failed: %s", e) for n in nodes: img = n.get('image_url', '') @@ -650,8 +650,8 @@ def get_artist_map_explore(): if row['genres']: try: center_genres = json.loads(row['genres']) if isinstance(row['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("initial center genres parse failed: %s", e) # Check watchlist + library if not in cache if not artist_found and not artist_id: @@ -722,8 +722,8 @@ def get_artist_map_explore(): if r['genres'] and not center_genres: try: center_genres = json.loads(r['genres']) if isinstance(r['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("center genres parse failed: %s", e) # Add center node center_idx = 0 @@ -787,8 +787,8 @@ def get_artist_map_explore(): popularity=sa.get('popularity', 0), similar_artist_deezer_id=sa.get('deezer_id') ) - except Exception: - pass + except Exception as e: + logger.debug("similar artist insert failed: %s", e) # Re-query from DB to get consistent format if id_values: placeholders = ','.join(['?'] * len(id_values)) @@ -828,8 +828,8 @@ def get_artist_map_explore(): if r['genres']: try: genres = json.loads(r['genres']) if isinstance(r['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("ring1 genres parse failed: %s", e) img = r['image_url'] if r['image_url'] and r['image_url'].startswith('http') else '' nodes.append({ 'id': idx, 'name': r['similar_artist_name'], 'image_url': img, @@ -889,8 +889,8 @@ def get_artist_map_explore(): if r['genres']: try: genres = json.loads(r['genres']) if isinstance(r['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("ring2 genres parse failed: %s", e) img = r['image_url'] if r['image_url'] and r['image_url'].startswith('http') else '' nodes.append({ 'id': idx, 'name': r['similar_artist_name'], 'image_url': img, @@ -928,8 +928,8 @@ def get_artist_map_explore(): if not n['genres'] and cr['genres']: try: n['genres'] = json.loads(cr['genres'])[:5] if isinstance(cr['genres'], str) else [] - except Exception: - pass + except Exception as e: + logger.debug("explorer node genres parse failed: %s", e) # Harvest missing IDs from cache src_map = {'spotify': 'spotify_id', 'itunes': 'itunes_id', 'deezer': 'deezer_id', 'discogs': 'discogs_id'} k = src_map.get(cr['source']) @@ -951,8 +951,8 @@ def get_artist_map_explore(): n['image_url'] = artist_data['images'][0]['url'] if not n['genres'] and artist_data.get('genres'): n['genres'] = artist_data['genres'][:5] - except Exception: - pass + except Exception as e: + logger.debug("spotify artist image fallback failed: %s", e) # Album art fallback (iTunes artists have no artist images) if not n['image_url']: