Add New Music Category for Media Browser (#128147)
parent
11d9a71e5d
commit
0c6a640e50
|
@ -18,7 +18,15 @@ from homeassistant.components.media_player import (
|
|||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.network import is_internal_request
|
||||
|
||||
LIBRARY = ["Favorites", "Artists", "Albums", "Tracks", "Playlists", "Genres"]
|
||||
LIBRARY = [
|
||||
"Favorites",
|
||||
"Artists",
|
||||
"Albums",
|
||||
"Tracks",
|
||||
"Playlists",
|
||||
"Genres",
|
||||
"New Music",
|
||||
]
|
||||
|
||||
MEDIA_TYPE_TO_SQUEEZEBOX = {
|
||||
"Favorites": "favorites",
|
||||
|
@ -27,6 +35,7 @@ MEDIA_TYPE_TO_SQUEEZEBOX = {
|
|||
"Tracks": "titles",
|
||||
"Playlists": "playlists",
|
||||
"Genres": "genres",
|
||||
"New Music": "new music",
|
||||
MediaType.ALBUM: "album",
|
||||
MediaType.ARTIST: "artist",
|
||||
MediaType.TRACK: "title",
|
||||
|
@ -50,6 +59,7 @@ CONTENT_TYPE_MEDIA_CLASS: dict[str | MediaType, dict[str, MediaClass | None]] =
|
|||
"Tracks": {"item": MediaClass.DIRECTORY, "children": MediaClass.TRACK},
|
||||
"Playlists": {"item": MediaClass.DIRECTORY, "children": MediaClass.PLAYLIST},
|
||||
"Genres": {"item": MediaClass.DIRECTORY, "children": MediaClass.GENRE},
|
||||
"New Music": {"item": MediaClass.DIRECTORY, "children": MediaClass.ALBUM},
|
||||
MediaType.ALBUM: {"item": MediaClass.ALBUM, "children": MediaClass.TRACK},
|
||||
MediaType.ARTIST: {"item": MediaClass.ARTIST, "children": MediaClass.ALBUM},
|
||||
MediaType.TRACK: {"item": MediaClass.TRACK, "children": None},
|
||||
|
@ -68,6 +78,7 @@ CONTENT_TYPE_TO_CHILD_TYPE = {
|
|||
"Playlists": MediaType.PLAYLIST,
|
||||
"Genres": MediaType.GENRE,
|
||||
"Favorites": None, # can only be determined after inspecting the item
|
||||
"New Music": MediaType.ALBUM,
|
||||
}
|
||||
|
||||
BROWSE_LIMIT = 1000
|
||||
|
|
|
@ -120,6 +120,7 @@ async def mock_async_browse(
|
|||
"""Mock the async_browse method of pysqueezebox.Player."""
|
||||
child_types = {
|
||||
"favorites": "favorites",
|
||||
"new music": "album",
|
||||
"albums": "album",
|
||||
"album": "track",
|
||||
"genres": "genre",
|
||||
|
|
|
@ -72,7 +72,14 @@ async def test_async_browse_media_with_subitems(
|
|||
hass_ws_client: WebSocketGenerator,
|
||||
) -> None:
|
||||
"""Test each category with subitems."""
|
||||
for category in ("Favorites", "Artists", "Albums", "Playlists", "Genres"):
|
||||
for category in (
|
||||
"Favorites",
|
||||
"Artists",
|
||||
"Albums",
|
||||
"Playlists",
|
||||
"Genres",
|
||||
"New Music",
|
||||
):
|
||||
with patch(
|
||||
"homeassistant.components.squeezebox.browse_media.is_internal_request",
|
||||
return_value=False,
|
||||
|
|
Loading…
Reference in New Issue