File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
music_assistant/controllers/media Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -458,19 +458,23 @@ async def _set_album_artist(
458458 self , db_id : int , artist : Artist | ItemMapping , overwrite : bool = False
459459 ) -> ItemMapping :
460460 """Store Album Artist info."""
461- db_artist : Artist | ItemMapping
461+ db_artist : Artist | ItemMapping | None = None
462462 if artist .provider == "library" :
463463 db_artist = artist
464464 elif existing := await self .mass .music .artists .get_library_item_by_prov_id (
465465 artist .item_id , artist .provider
466466 ):
467467 db_artist = existing
468- elif isinstance (artist , Artist ):
469- db_artist = await self .mass .music .artists .add_item_to_library (
470- artist , overwrite_existing = overwrite
471- )
472- else :
473- db_artist = artist
468+
469+ if not db_artist or overwrite :
470+ # Type narrowing: if artist is an ItemMapping, convert it or handle it
471+ if isinstance (artist , ItemMapping ):
472+ # ItemMapping can't be added directly, use the existing or skip
473+ db_artist = artist
474+ else :
475+ db_artist = await self .mass .music .artists .add_item_to_library (
476+ artist , overwrite_existing = overwrite
477+ )
474478 # write (or update) record in album_artists table
475479 assert self .mass .music .database is not None
476480 await self .mass .music .database .insert_or_replace (
You can’t perform that action at this time.
0 commit comments