Skip to content

Commit

Permalink
Add New Music Category for Media Browser (#128147)
Browse files Browse the repository at this point in the history
  • Loading branch information
peteS-UK authored Oct 20, 2024
1 parent 11d9a71 commit 0c6a640
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
13 changes: 12 additions & 1 deletion homeassistant/components/squeezebox/browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@
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",
Expand All @@ -27,6 +35,7 @@
"Tracks": "titles",
"Playlists": "playlists",
"Genres": "genres",
"New Music": "new music",
MediaType.ALBUM: "album",
MediaType.ARTIST: "artist",
MediaType.TRACK: "title",
Expand All @@ -50,6 +59,7 @@
"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},
Expand All @@ -68,6 +78,7 @@
"Playlists": MediaType.PLAYLIST,
"Genres": MediaType.GENRE,
"Favorites": None, # can only be determined after inspecting the item
"New Music": MediaType.ALBUM,
}

BROWSE_LIMIT = 1000
Expand Down
1 change: 1 addition & 0 deletions tests/components/squeezebox/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion tests/components/squeezebox/test_media_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0c6a640

Please sign in to comment.