From ef41e5f8b3a1e6bd23943a167a4cec63a49aeaec Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Sun, 19 Apr 2026 09:20:22 -0700 Subject: [PATCH] Fix artist sync 'Artist not found' for Navidrome/Jellyfin text IDs The ID resolver tried int() conversion first, which fails for text-based IDs from Navidrome/Jellyfin. Now tries direct string match first (works for both text and integer IDs), then integer fallback, then source columns. Also added discogs_id to source column search. Fixes #323 --- web_server.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/web_server.py b/web_server.py index 0e8932b9..c4c684ec 100644 --- a/web_server.py +++ b/web_server.py @@ -15637,15 +15637,24 @@ def sync_artist_library(artist_id): # Resolve artist_id: could be a DB integer ID or a source artist ID (Spotify/iTunes/Deezer) db_artist_id = None - try: - candidate = int(artist_id) - cursor.execute("SELECT id FROM artists WHERE id = ?", (candidate,)) - if cursor.fetchone(): - db_artist_id = candidate - except (ValueError, TypeError): - pass + # Try direct ID match first (works for both integer and text IDs) + cursor.execute("SELECT id FROM artists WHERE id = ?", (artist_id,)) + row = cursor.fetchone() + if row: + db_artist_id = row['id'] + # Also try as integer (legacy integer PKs) + if not db_artist_id: + try: + candidate = int(artist_id) + cursor.execute("SELECT id FROM artists WHERE id = ?", (candidate,)) + row = cursor.fetchone() + if row: + db_artist_id = row['id'] + except (ValueError, TypeError): + pass + # Try source-specific ID columns if not db_artist_id: - for col in ('spotify_artist_id', 'itunes_artist_id', 'deezer_id'): + for col in ('spotify_artist_id', 'itunes_artist_id', 'deezer_id', 'discogs_id'): cursor.execute(f"SELECT id FROM artists WHERE {col} = ?", (artist_id,)) row = cursor.fetchone() if row: