@ -648,66 +648,6 @@ class WatchlistScanner:
image_url = image_url ,
)
def _get_active_client_and_artist_id ( self , watchlist_artist : WatchlistArtist ) :
"""
Get the appropriate client and artist ID based on active provider .
If iTunes ID is missing , searches by artist name to find and cache it .
Returns :
Tuple of ( client , artist_id , provider_name ) or ( None , None , None ) if no valid ID
"""
provider = self . metadata_service . get_active_provider ( )
if provider == ' spotify ' :
if watchlist_artist . spotify_artist_id :
return ( self . metadata_service . spotify , watchlist_artist . spotify_artist_id , ' spotify ' )
else :
logger . warning ( f " No Spotify ID for { watchlist_artist . artist_name } , cannot scan with Spotify " )
return ( None , None , None )
else : # itunes or deezer fallback
fallback_source = provider # 'itunes' or 'deezer'
fallback_client = self . metadata_service . itunes # May be iTunesClient or DeezerClient
# Pick the right stored ID for the active fallback source
stored_id = watchlist_artist . deezer_artist_id if fallback_source == ' deezer ' else watchlist_artist . itunes_artist_id
if stored_id :
return ( fallback_client , stored_id , fallback_source )
else :
# No ID stored for this source - search by name and cache it
logger . info ( f " No { fallback_source } ID for { watchlist_artist . artist_name } , searching by name... " )
try :
search_results = fallback_client . search_artists ( watchlist_artist . artist_name , limit = 1 )
if search_results and len ( search_results ) > 0 :
found_id = search_results [ 0 ] . id
logger . info ( f " Found { fallback_source } ID { found_id } for { watchlist_artist . artist_name } " )
# Cache the ID in the database for future use
if fallback_source == ' deezer ' :
self . database . update_watchlist_artist_deezer_id (
watchlist_artist . spotify_artist_id or str ( watchlist_artist . id ) ,
found_id
)
else :
self . database . update_watchlist_artist_itunes_id (
watchlist_artist . spotify_artist_id or str ( watchlist_artist . id ) ,
found_id
)
return ( fallback_client , found_id , fallback_source )
else :
logger . warning ( f " Could not find { watchlist_artist . artist_name } on { fallback_source } " )
return ( None , None , None )
except Exception as e :
logger . error ( f " Error searching { fallback_source } for { watchlist_artist . artist_name } : { e } " )
return ( None , None , None )
def get_active_client_and_artist_id ( self , watchlist_artist : WatchlistArtist ) :
"""
Public wrapper for _get_active_client_and_artist_id .
Gets the appropriate client and artist ID based on active provider .
Returns :
Tuple of ( client , artist_id , provider_name ) or ( None , None , None ) if no valid ID
"""
return self . _get_active_client_and_artist_id ( watchlist_artist )
def get_artist_image_url ( self , watchlist_artist : WatchlistArtist ) - > Optional [ str ] :
"""
Get artist image URL using the configured source priority .