mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Handle more Sonos favorites in media browser (#66205)
This commit is contained in:
parent
0199e8cc43
commit
854308fec2
@ -44,6 +44,7 @@ SONOS_ALBUM_ARTIST = "album_artists"
|
||||
SONOS_TRACKS = "tracks"
|
||||
SONOS_COMPOSER = "composers"
|
||||
SONOS_RADIO = "radio"
|
||||
SONOS_OTHER_ITEM = "other items"
|
||||
|
||||
SONOS_STATE_PLAYING = "PLAYING"
|
||||
SONOS_STATE_TRANSITIONING = "TRANSITIONING"
|
||||
@ -76,6 +77,7 @@ SONOS_TO_MEDIA_CLASSES = {
|
||||
"object.container.person.musicArtist": MEDIA_CLASS_ARTIST,
|
||||
"object.container.playlistContainer.sameArtist": MEDIA_CLASS_ARTIST,
|
||||
"object.container.playlistContainer": MEDIA_CLASS_PLAYLIST,
|
||||
"object.item": MEDIA_CLASS_TRACK,
|
||||
"object.item.audioItem.musicTrack": MEDIA_CLASS_TRACK,
|
||||
"object.item.audioItem.audioBroadcast": MEDIA_CLASS_GENRE,
|
||||
}
|
||||
@ -121,6 +123,7 @@ SONOS_TYPES_MAPPING = {
|
||||
"object.container.person.musicArtist": SONOS_ALBUM_ARTIST,
|
||||
"object.container.playlistContainer.sameArtist": SONOS_ARTIST,
|
||||
"object.container.playlistContainer": SONOS_PLAYLISTS,
|
||||
"object.item": SONOS_OTHER_ITEM,
|
||||
"object.item.audioItem.musicTrack": SONOS_TRACKS,
|
||||
"object.item.audioItem.audioBroadcast": SONOS_RADIO,
|
||||
}
|
||||
|
@ -162,8 +162,17 @@ def build_item_response(media_library, payload, get_thumbnail_url=None):
|
||||
payload["idstring"].split("/")[2:]
|
||||
)
|
||||
|
||||
try:
|
||||
search_type = MEDIA_TYPES_TO_SONOS[payload["search_type"]]
|
||||
except KeyError:
|
||||
_LOGGER.debug(
|
||||
"Unknown media type received when building item response: %s",
|
||||
payload["search_type"],
|
||||
)
|
||||
return
|
||||
|
||||
media = media_library.browse_by_idstring(
|
||||
MEDIA_TYPES_TO_SONOS[payload["search_type"]],
|
||||
search_type,
|
||||
payload["idstring"],
|
||||
full_album_art_uri=True,
|
||||
max_items=0,
|
||||
@ -371,11 +380,16 @@ def favorites_payload(favorites):
|
||||
|
||||
group_types = {fav.reference.item_class for fav in favorites}
|
||||
for group_type in sorted(group_types):
|
||||
media_content_type = SONOS_TYPES_MAPPING[group_type]
|
||||
try:
|
||||
media_content_type = SONOS_TYPES_MAPPING[group_type]
|
||||
media_class = SONOS_TO_MEDIA_CLASSES[group_type]
|
||||
except KeyError:
|
||||
_LOGGER.debug("Unknown media type or class received %s", group_type)
|
||||
continue
|
||||
children.append(
|
||||
BrowseMedia(
|
||||
title=media_content_type.title(),
|
||||
media_class=SONOS_TO_MEDIA_CLASSES[group_type],
|
||||
media_class=media_class,
|
||||
media_content_id=group_type,
|
||||
media_content_type="favorites_folder",
|
||||
can_play=False,
|
||||
|
Loading…
x
Reference in New Issue
Block a user