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)
|
# Resolve artist_id: could be a DB integer ID or a source artist ID (Spotify/iTunes/Deezer)
|
||||||
db_artist_id = None
|
db_artist_id = None
|
||||||
try:
|
# Try direct ID match first (works for both integer and text IDs)
|
||||||
candidate = int(artist_id)
|
cursor.execute("SELECT id FROM artists WHERE id = ?", (artist_id,))
|
||||||
cursor.execute("SELECT id FROM artists WHERE id = ?", (candidate,))
|
row = cursor.fetchone()
|
||||||
if cursor.fetchone():
|
if row:
|
||||||
db_artist_id = candidate
|
db_artist_id = row['id']
|
||||||
except (ValueError, TypeError):
|
# Also try as integer (legacy integer PKs)
|
||||||
pass
|
|
||||||
if not db_artist_id:
|
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,))
|
cursor.execute(f"SELECT id FROM artists WHERE {col} = ?", (artist_id,))
|
||||||
row = cursor.fetchone()
|
row = cursor.fetchone()
|
||||||
if row:
|
if row:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue