Fix adding an item to library from browse results (#3120)
authorMarvin Schenkel <marvinschenkel@gmail.com>
Tue, 10 Feb 2026 07:53:38 +0000 (08:53 +0100)
committerGitHub <noreply@github.com>
Tue, 10 Feb 2026 07:53:38 +0000 (08:53 +0100)
* Fix adding an item from browse results to library

* Fix adding an item from browse results to library

* Change dict to ItemMapping

music_assistant/controllers/music.py

index c8149b0a2fc9bfa56530968cd07708f5068d3511..391a559c19ff48fee4e6d005483ebd2c49b8e617 100644 (file)
@@ -876,9 +876,12 @@ class MusicController(CoreController):
 
     @api_command("music/library/add_item")
     async def add_item_to_library(
-        self, item: str | MediaItemType, overwrite_existing: bool = False
+        self, item: str | MediaItemType | ItemMapping, overwrite_existing: bool = False
     ) -> MediaItemType:
         """Add item (uri or mediaitem) to the library."""
+        if isinstance(item, ItemMapping):
+            # handle browse results that are returned as ItemMappings
+            item = item.uri
         # ensure we have a full item
         if isinstance(item, str):
             full_item = await self.get_item_by_uri(item)