mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Add New Music Category for Media Browser (#128147)
This commit is contained in:
parent
11d9a71e5d
commit
0c6a640e50
@ -18,7 +18,15 @@ from homeassistant.components.media_player import (
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.network import is_internal_request
|
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 = {
|
MEDIA_TYPE_TO_SQUEEZEBOX = {
|
||||||
"Favorites": "favorites",
|
"Favorites": "favorites",
|
||||||
@ -27,6 +35,7 @@ MEDIA_TYPE_TO_SQUEEZEBOX = {
|
|||||||
"Tracks": "titles",
|
"Tracks": "titles",
|
||||||
"Playlists": "playlists",
|
"Playlists": "playlists",
|
||||||
"Genres": "genres",
|
"Genres": "genres",
|
||||||
|
"New Music": "new music",
|
||||||
MediaType.ALBUM: "album",
|
MediaType.ALBUM: "album",
|
||||||
MediaType.ARTIST: "artist",
|
MediaType.ARTIST: "artist",
|
||||||
MediaType.TRACK: "title",
|
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},
|
"Tracks": {"item": MediaClass.DIRECTORY, "children": MediaClass.TRACK},
|
||||||
"Playlists": {"item": MediaClass.DIRECTORY, "children": MediaClass.PLAYLIST},
|
"Playlists": {"item": MediaClass.DIRECTORY, "children": MediaClass.PLAYLIST},
|
||||||
"Genres": {"item": MediaClass.DIRECTORY, "children": MediaClass.GENRE},
|
"Genres": {"item": MediaClass.DIRECTORY, "children": MediaClass.GENRE},
|
||||||
|
"New Music": {"item": MediaClass.DIRECTORY, "children": MediaClass.ALBUM},
|
||||||
MediaType.ALBUM: {"item": MediaClass.ALBUM, "children": MediaClass.TRACK},
|
MediaType.ALBUM: {"item": MediaClass.ALBUM, "children": MediaClass.TRACK},
|
||||||
MediaType.ARTIST: {"item": MediaClass.ARTIST, "children": MediaClass.ALBUM},
|
MediaType.ARTIST: {"item": MediaClass.ARTIST, "children": MediaClass.ALBUM},
|
||||||
MediaType.TRACK: {"item": MediaClass.TRACK, "children": None},
|
MediaType.TRACK: {"item": MediaClass.TRACK, "children": None},
|
||||||
@ -68,6 +78,7 @@ CONTENT_TYPE_TO_CHILD_TYPE = {
|
|||||||
"Playlists": MediaType.PLAYLIST,
|
"Playlists": MediaType.PLAYLIST,
|
||||||
"Genres": MediaType.GENRE,
|
"Genres": MediaType.GENRE,
|
||||||
"Favorites": None, # can only be determined after inspecting the item
|
"Favorites": None, # can only be determined after inspecting the item
|
||||||
|
"New Music": MediaType.ALBUM,
|
||||||
}
|
}
|
||||||
|
|
||||||
BROWSE_LIMIT = 1000
|
BROWSE_LIMIT = 1000
|
||||||
|
@ -120,6 +120,7 @@ async def mock_async_browse(
|
|||||||
"""Mock the async_browse method of pysqueezebox.Player."""
|
"""Mock the async_browse method of pysqueezebox.Player."""
|
||||||
child_types = {
|
child_types = {
|
||||||
"favorites": "favorites",
|
"favorites": "favorites",
|
||||||
|
"new music": "album",
|
||||||
"albums": "album",
|
"albums": "album",
|
||||||
"album": "track",
|
"album": "track",
|
||||||
"genres": "genre",
|
"genres": "genre",
|
||||||
|
@ -72,7 +72,14 @@ async def test_async_browse_media_with_subitems(
|
|||||||
hass_ws_client: WebSocketGenerator,
|
hass_ws_client: WebSocketGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test each category with subitems."""
|
"""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(
|
with patch(
|
||||||
"homeassistant.components.squeezebox.browse_media.is_internal_request",
|
"homeassistant.components.squeezebox.browse_media.is_internal_request",
|
||||||
return_value=False,
|
return_value=False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user