Skip to content
Snippets Groups Projects
Unverified Commit d4f38099 authored by peteS-UK's avatar peteS-UK Committed by GitHub
Browse files

Small fix to allow playing of expandable favorites on Squeezebox (#134572)

parent 9f2cb7bf
No related branches found
No related tags found
No related merge requests found
...@@ -115,6 +115,7 @@ async def build_item_response( ...@@ -115,6 +115,7 @@ async def build_item_response(
item_type = CONTENT_TYPE_TO_CHILD_TYPE[search_type] item_type = CONTENT_TYPE_TO_CHILD_TYPE[search_type]
children = [] children = []
list_playable = []
for item in result["items"]: for item in result["items"]:
item_id = str(item["id"]) item_id = str(item["id"])
item_thumbnail: str | None = None item_thumbnail: str | None = None
...@@ -131,7 +132,7 @@ async def build_item_response( ...@@ -131,7 +132,7 @@ async def build_item_response(
child_media_class = CONTENT_TYPE_MEDIA_CLASS[MediaType.ALBUM] child_media_class = CONTENT_TYPE_MEDIA_CLASS[MediaType.ALBUM]
can_expand = True can_expand = True
can_play = True can_play = True
elif item["hasitems"]: elif item["hasitems"] and not item["isaudio"]:
child_item_type = "Favorites" child_item_type = "Favorites"
child_media_class = CONTENT_TYPE_MEDIA_CLASS["Favorites"] child_media_class = CONTENT_TYPE_MEDIA_CLASS["Favorites"]
can_expand = True can_expand = True
...@@ -139,8 +140,8 @@ async def build_item_response( ...@@ -139,8 +140,8 @@ async def build_item_response(
else: else:
child_item_type = "Favorites" child_item_type = "Favorites"
child_media_class = CONTENT_TYPE_MEDIA_CLASS[MediaType.TRACK] child_media_class = CONTENT_TYPE_MEDIA_CLASS[MediaType.TRACK]
can_expand = False can_expand = item["hasitems"]
can_play = True can_play = item["isaudio"] and item.get("url")
if artwork_track_id := item.get("artwork_track_id"): if artwork_track_id := item.get("artwork_track_id"):
if internal_request: if internal_request:
...@@ -166,6 +167,7 @@ async def build_item_response( ...@@ -166,6 +167,7 @@ async def build_item_response(
thumbnail=item_thumbnail, thumbnail=item_thumbnail,
) )
) )
list_playable.append(can_play)
if children is None: if children is None:
raise BrowseError(f"Media not found: {search_type} / {search_id}") raise BrowseError(f"Media not found: {search_type} / {search_id}")
...@@ -179,7 +181,7 @@ async def build_item_response( ...@@ -179,7 +181,7 @@ async def build_item_response(
children_media_class=media_class["children"], children_media_class=media_class["children"],
media_content_id=search_id, media_content_id=search_id,
media_content_type=search_type, media_content_type=search_type,
can_play=search_type != "Favorites", can_play=any(list_playable),
children=children, children=children,
can_expand=True, can_expand=True,
) )
......
...@@ -137,6 +137,7 @@ async def mock_async_browse( ...@@ -137,6 +137,7 @@ async def mock_async_browse(
"title": "Fake Item 1", "title": "Fake Item 1",
"id": FAKE_VALID_ITEM_ID, "id": FAKE_VALID_ITEM_ID,
"hasitems": False, "hasitems": False,
"isaudio": True,
"item_type": child_types[media_type], "item_type": child_types[media_type],
"artwork_track_id": "b35bb9e9", "artwork_track_id": "b35bb9e9",
"url": "file:///var/lib/squeezeboxserver/music/track_1.mp3", "url": "file:///var/lib/squeezeboxserver/music/track_1.mp3",
...@@ -145,6 +146,7 @@ async def mock_async_browse( ...@@ -145,6 +146,7 @@ async def mock_async_browse(
"title": "Fake Item 2", "title": "Fake Item 2",
"id": FAKE_VALID_ITEM_ID + "_2", "id": FAKE_VALID_ITEM_ID + "_2",
"hasitems": media_type == "favorites", "hasitems": media_type == "favorites",
"isaudio": True,
"item_type": child_types[media_type], "item_type": child_types[media_type],
"image_url": "http://lms.internal:9000/html/images/favorites.png", "image_url": "http://lms.internal:9000/html/images/favorites.png",
"url": "file:///var/lib/squeezeboxserver/music/track_2.mp3", "url": "file:///var/lib/squeezeboxserver/music/track_2.mp3",
...@@ -153,6 +155,7 @@ async def mock_async_browse( ...@@ -153,6 +155,7 @@ async def mock_async_browse(
"title": "Fake Item 3", "title": "Fake Item 3",
"id": FAKE_VALID_ITEM_ID + "_3", "id": FAKE_VALID_ITEM_ID + "_3",
"hasitems": media_type == "favorites", "hasitems": media_type == "favorites",
"isaudio": True,
"album_id": FAKE_VALID_ITEM_ID if media_type == "favorites" else None, "album_id": FAKE_VALID_ITEM_ID if media_type == "favorites" else None,
"url": "file:///var/lib/squeezeboxserver/music/track_3.mp3", "url": "file:///var/lib/squeezeboxserver/music/track_3.mp3",
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment