diff --git a/homeassistant/components/roku/browse_media.py b/homeassistant/components/roku/browse_media.py index f6f8c8976f1..b5be3e99d9a 100644 --- a/homeassistant/components/roku/browse_media.py +++ b/homeassistant/components/roku/browse_media.py @@ -13,8 +13,13 @@ from homeassistant.components.media_player.const import ( CONTENT_TYPE_MEDIA_CLASS = { MEDIA_TYPE_APP: MEDIA_CLASS_APP, - MEDIA_TYPE_APPS: MEDIA_CLASS_DIRECTORY, + MEDIA_TYPE_APPS: MEDIA_CLASS_APP, MEDIA_TYPE_CHANNEL: MEDIA_CLASS_CHANNEL, + MEDIA_TYPE_CHANNELS: MEDIA_CLASS_CHANNEL, +} + +CONTAINER_TYPES_SPECIFIC_MEDIA_CLASS = { + MEDIA_TYPE_APPS: MEDIA_CLASS_DIRECTORY, MEDIA_TYPE_CHANNELS: MEDIA_CLASS_DIRECTORY, } @@ -37,6 +42,7 @@ def build_item_response(coordinator, payload): thumbnail = None title = None media = None + children_media_class = None if search_type == MEDIA_TYPE_APPS: title = "Apps" @@ -44,6 +50,7 @@ def build_item_response(coordinator, payload): {"app_id": item.app_id, "title": item.name, "type": MEDIA_TYPE_APP} for item in coordinator.data.apps ] + children_media_class = MEDIA_CLASS_APP elif search_type == MEDIA_TYPE_CHANNELS: title = "Channels" media = [ @@ -54,18 +61,22 @@ def build_item_response(coordinator, payload): } for item in coordinator.data.channels ] + children_media_class = MEDIA_CLASS_CHANNEL if media is None: return None return BrowseMedia( - media_class=MEDIA_CLASS_DIRECTORY, + media_class=CONTAINER_TYPES_SPECIFIC_MEDIA_CLASS.get( + search_type, MEDIA_CLASS_DIRECTORY + ), media_content_id=search_id, media_content_type=search_type, title=title, can_play=search_type in PLAYABLE_MEDIA_TYPES and search_id, can_expand=True, children=[item_payload(item, coordinator) for item in media], + children_media_class=children_media_class, thumbnail=thumbnail, ) @@ -148,7 +159,5 @@ def library_payload(coordinator): for child in library_info.children ): library_info.children_media_class = MEDIA_CLASS_CHANNEL - else: - library_info.children_media_class = MEDIA_CLASS_DIRECTORY return library_info diff --git a/tests/components/roku/test_media_player.py b/tests/components/roku/test_media_player.py index e9d5091d664..b4ce1811c91 100644 --- a/tests/components/roku/test_media_player.py +++ b/tests/components/roku/test_media_player.py @@ -529,6 +529,7 @@ async def test_media_browse(hass, aioclient_mock, hass_ws_client): assert msg["result"]["title"] == "Apps" assert msg["result"]["media_class"] == MEDIA_CLASS_DIRECTORY assert msg["result"]["media_content_type"] == MEDIA_TYPE_APPS + assert msg["result"]["children_media_class"] == MEDIA_CLASS_APP assert msg["result"]["can_expand"] assert not msg["result"]["can_play"] assert len(msg["result"]["children"]) == 11 @@ -573,6 +574,7 @@ async def test_media_browse(hass, aioclient_mock, hass_ws_client): assert msg["result"]["title"] == "Channels" assert msg["result"]["media_class"] == MEDIA_CLASS_DIRECTORY assert msg["result"]["media_content_type"] == MEDIA_TYPE_CHANNELS + assert msg["result"]["children_media_class"] == MEDIA_CLASS_CHANNEL assert msg["result"]["can_expand"] assert not msg["result"]["can_play"] assert len(msg["result"]["children"]) == 2