mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 22:37:11 +00:00
Small fix to allow playing of expandable favorites on Squeezebox (#134572)
This commit is contained in:
parent
9f2cb7bf56
commit
d4f38099ae
@ -115,6 +115,7 @@ async def build_item_response(
|
||||
item_type = CONTENT_TYPE_TO_CHILD_TYPE[search_type]
|
||||
|
||||
children = []
|
||||
list_playable = []
|
||||
for item in result["items"]:
|
||||
item_id = str(item["id"])
|
||||
item_thumbnail: str | None = None
|
||||
@ -131,7 +132,7 @@ async def build_item_response(
|
||||
child_media_class = CONTENT_TYPE_MEDIA_CLASS[MediaType.ALBUM]
|
||||
can_expand = True
|
||||
can_play = True
|
||||
elif item["hasitems"]:
|
||||
elif item["hasitems"] and not item["isaudio"]:
|
||||
child_item_type = "Favorites"
|
||||
child_media_class = CONTENT_TYPE_MEDIA_CLASS["Favorites"]
|
||||
can_expand = True
|
||||
@ -139,8 +140,8 @@ async def build_item_response(
|
||||
else:
|
||||
child_item_type = "Favorites"
|
||||
child_media_class = CONTENT_TYPE_MEDIA_CLASS[MediaType.TRACK]
|
||||
can_expand = False
|
||||
can_play = True
|
||||
can_expand = item["hasitems"]
|
||||
can_play = item["isaudio"] and item.get("url")
|
||||
|
||||
if artwork_track_id := item.get("artwork_track_id"):
|
||||
if internal_request:
|
||||
@ -166,6 +167,7 @@ async def build_item_response(
|
||||
thumbnail=item_thumbnail,
|
||||
)
|
||||
)
|
||||
list_playable.append(can_play)
|
||||
|
||||
if children is None:
|
||||
raise BrowseError(f"Media not found: {search_type} / {search_id}")
|
||||
@ -179,7 +181,7 @@ async def build_item_response(
|
||||
children_media_class=media_class["children"],
|
||||
media_content_id=search_id,
|
||||
media_content_type=search_type,
|
||||
can_play=search_type != "Favorites",
|
||||
can_play=any(list_playable),
|
||||
children=children,
|
||||
can_expand=True,
|
||||
)
|
||||
|
@ -137,6 +137,7 @@ async def mock_async_browse(
|
||||
"title": "Fake Item 1",
|
||||
"id": FAKE_VALID_ITEM_ID,
|
||||
"hasitems": False,
|
||||
"isaudio": True,
|
||||
"item_type": child_types[media_type],
|
||||
"artwork_track_id": "b35bb9e9",
|
||||
"url": "file:///var/lib/squeezeboxserver/music/track_1.mp3",
|
||||
@ -145,6 +146,7 @@ async def mock_async_browse(
|
||||
"title": "Fake Item 2",
|
||||
"id": FAKE_VALID_ITEM_ID + "_2",
|
||||
"hasitems": media_type == "favorites",
|
||||
"isaudio": True,
|
||||
"item_type": child_types[media_type],
|
||||
"image_url": "http://lms.internal:9000/html/images/favorites.png",
|
||||
"url": "file:///var/lib/squeezeboxserver/music/track_2.mp3",
|
||||
@ -153,6 +155,7 @@ async def mock_async_browse(
|
||||
"title": "Fake Item 3",
|
||||
"id": FAKE_VALID_ITEM_ID + "_3",
|
||||
"hasitems": media_type == "favorites",
|
||||
"isaudio": True,
|
||||
"album_id": FAKE_VALID_ITEM_ID if media_type == "favorites" else None,
|
||||
"url": "file:///var/lib/squeezeboxserver/music/track_3.mp3",
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user