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
This commit is contained in:
parent
afc91c1397
commit
ef41e5f8b3
1 changed files with 17 additions and 8 deletions
|
|
@ -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:
|
||||
for col in ('spotify_artist_id', 'itunes_artist_id', 'deezer_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', 'discogs_id'):
|
||||
cursor.execute(f"SELECT id FROM artists WHERE {col} = ?", (artist_id,))
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
|
|
|
|||
Loading…
Reference in a new issue