available only
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 3 Apr 2023 08:26:41 +0000 (10:26 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 3 Apr 2023 08:26:41 +0000 (10:26 +0200)
music_assistant/server/controllers/media/base.py

index 2ceb641d6c1b318bb8a4a46ede035c3673826f4b..1f35f066e8ba3164d6ccb0c84446545f436bd30e 100644 (file)
@@ -284,18 +284,15 @@ class MediaControllerBase(Generic[ItemCls], metaclass=ABCMeta):
         if not getattr(item, "provider_mappings", None):
             # make sure we have a full object
             item = await self.get_db_item(item.item_id)
-        for prefer_available in (True, False):
-            for prefer_unique in (True, False):
-                for prov_mapping in item.provider_mappings:
-                    # returns the first provider that is available
-                    if prefer_available and not prov_mapping.available:
+        for prefer_unique in (True, False):
+            for prov_mapping in item.provider_mappings:
+                # returns the first provider that is available
+                if not prov_mapping.available:
+                    continue
+                if provider := self.mass.get_provider(prov_mapping.provider_instance):
+                    if prefer_unique and not provider.is_unique:
                         continue
-                    if provider := self.mass.get_provider(
-                        prov_mapping.provider_instance, return_unavailable=not prefer_available
-                    ):
-                        if prefer_unique and not provider.is_unique:
-                            continue
-                        return (prov_mapping.provider_instance, prov_mapping.item_id)
+                    return (prov_mapping.provider_instance, prov_mapping.item_id)
         return (None, None)
 
     async def get_db_items_by_query(