mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Album art not available for Sonos media library favorites (#140557)
* get album art uri for favorites * add tests * update typing * update typing * update typing * simplify
This commit is contained in:
parent
43e24cf833
commit
88e3dcccda
@ -105,7 +105,7 @@ class SonosFavorites(SonosHouseholdCoordinator):
|
||||
@soco_error()
|
||||
def update_cache(self, soco: SoCo, update_id: int | None = None) -> bool:
|
||||
"""Update cache of known favorites and return if cache has changed."""
|
||||
new_favorites = soco.music_library.get_sonos_favorites()
|
||||
new_favorites = soco.music_library.get_sonos_favorites(full_album_art_uri=True)
|
||||
|
||||
# Polled update_id values do not match event_id values
|
||||
# Each speaker can return a different polled update_id
|
||||
|
@ -165,6 +165,8 @@ async def async_browse_media(
|
||||
favorites_folder_payload,
|
||||
speaker.favorites,
|
||||
media_content_id,
|
||||
media,
|
||||
get_browse_image_url,
|
||||
)
|
||||
|
||||
payload = {
|
||||
@ -443,7 +445,10 @@ def favorites_payload(favorites: SonosFavorites) -> BrowseMedia:
|
||||
|
||||
|
||||
def favorites_folder_payload(
|
||||
favorites: SonosFavorites, media_content_id: str
|
||||
favorites: SonosFavorites,
|
||||
media_content_id: str,
|
||||
media: SonosMedia,
|
||||
get_browse_image_url: GetBrowseImageUrlType,
|
||||
) -> BrowseMedia:
|
||||
"""Create response payload to describe all items of a type of favorite.
|
||||
|
||||
@ -463,7 +468,14 @@ def favorites_folder_payload(
|
||||
media_content_type="favorite_item_id",
|
||||
can_play=True,
|
||||
can_expand=False,
|
||||
thumbnail=getattr(favorite, "album_art_uri", None),
|
||||
thumbnail=get_thumbnail_url_full(
|
||||
media=media,
|
||||
is_internal=True,
|
||||
media_content_type="favorite_item_id",
|
||||
media_content_id=favorite.item_id,
|
||||
get_browse_image_url=get_browse_image_url,
|
||||
item=favorite,
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
"title": "1984",
|
||||
"parent_id": "FV:2",
|
||||
"item_id": "FV:2/8",
|
||||
"album_art_uri": "http://192.168.42.2:1400/getaa?u=x-file-cifs%3a%2f%2f192.168.42.2%2fmusic%2fiTunes%2520Music%2fAerosmith%2f1984&v=742",
|
||||
"resource_meta_data": "<DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"><item id=\"A:ALBUMARTIST/Aerosmith/1984\" parentID=\"A:ALBUMARTIST/Aerosmith\" restricted=\"true\"><dc:title>1984</dc:title><upnp:class>object.container.album.musicAlbum</upnp:class><desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\">RINCON_AssociatedZPUDN</desc></item></DIDL-Lite>",
|
||||
"resources": [
|
||||
{
|
||||
|
@ -44,6 +44,31 @@
|
||||
'title': 'Favorites',
|
||||
})
|
||||
# ---
|
||||
# name: test_browse_media_favorites[object.container.album.musicAlbum-favorites_folder]
|
||||
dict({
|
||||
'can_expand': True,
|
||||
'can_play': False,
|
||||
'children': list([
|
||||
dict({
|
||||
'can_expand': False,
|
||||
'can_play': True,
|
||||
'children_media_class': None,
|
||||
'media_class': 'album',
|
||||
'media_content_id': 'FV:2/8',
|
||||
'media_content_type': 'favorite_item_id',
|
||||
'thumbnail': 'http://192.168.42.2:1400/getaa?u=x-file-cifs://192.168.42.2/music/iTunes%20Music/Aerosmith/1984&v=742',
|
||||
'title': '1984',
|
||||
}),
|
||||
]),
|
||||
'children_media_class': 'album',
|
||||
'media_class': 'directory',
|
||||
'media_content_id': '',
|
||||
'media_content_type': 'favorites',
|
||||
'not_shown': 0,
|
||||
'thumbnail': None,
|
||||
'title': 'Albums',
|
||||
})
|
||||
# ---
|
||||
# name: test_browse_media_favorites[object.item.audioItem.audioBook-favorites_folder]
|
||||
dict({
|
||||
'can_expand': True,
|
||||
|
@ -190,6 +190,10 @@ async def test_browse_media_library_albums(
|
||||
"object.item.audioItem.audioBook",
|
||||
"favorites_folder",
|
||||
),
|
||||
(
|
||||
"object.container.album.musicAlbum",
|
||||
"favorites_folder",
|
||||
),
|
||||
],
|
||||
)
|
||||
async def test_browse_media_favorites(
|
||||
|
Loading…
x
Reference in New Issue
Block a user