mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Jellyfin: display album primary art instead of artist backdrop (#141246)
* Jellyfin: Properly display album primary art instead of artist backdrop when playing music * add test for album art urls, fix existing tests that broke because they have extraneous "album*" fields for non-album items. * fix snapshot test
This commit is contained in:
parent
0e6d72dcc8
commit
61a76b4064
@ -97,16 +97,27 @@ def get_artwork_url(
|
||||
client: JellyfinClient, item: dict[str, Any], max_width: int = 600
|
||||
) -> str | None:
|
||||
"""Find a suitable thumbnail for an item."""
|
||||
artwork_id: str = item["Id"]
|
||||
artwork_type = "Primary"
|
||||
artwork_id: str | None = None
|
||||
artwork_type: str | None = None
|
||||
parent_backdrop_id: str | None = item.get("ParentBackdropItemId")
|
||||
|
||||
if "Backdrop" in item[ITEM_KEY_IMAGE_TAGS]:
|
||||
if "AlbumPrimaryImageTag" in item:
|
||||
# jellyfin_apiclient_python doesn't support passing a specific tag to `.artwork`,
|
||||
# so we don't use the actual value of AlbumPrimaryImageTag.
|
||||
# However, its mere presence tells us that the album does have primary artwork,
|
||||
# and the resulting URL will pull the primary album art even if the tag is not specified.
|
||||
artwork_type = "Primary"
|
||||
artwork_id = item["AlbumId"]
|
||||
elif "Backdrop" in item[ITEM_KEY_IMAGE_TAGS]:
|
||||
artwork_type = "Backdrop"
|
||||
artwork_id = item["Id"]
|
||||
elif parent_backdrop_id:
|
||||
artwork_type = "Backdrop"
|
||||
artwork_id = parent_backdrop_id
|
||||
elif "Primary" not in item[ITEM_KEY_IMAGE_TAGS]:
|
||||
elif "Primary" in item[ITEM_KEY_IMAGE_TAGS]:
|
||||
artwork_type = "Primary"
|
||||
artwork_id = item["Id"]
|
||||
else:
|
||||
return None
|
||||
|
||||
return str(client.jellyfin.artwork(artwork_id, artwork_type, max_width))
|
||||
|
@ -302,8 +302,6 @@
|
||||
"Album": "string",
|
||||
"CollectionType": "tvshows",
|
||||
"DisplayOrder": "string",
|
||||
"AlbumId": "21af9851-8e39-43a9-9c47-513d3b9e99fc",
|
||||
"AlbumPrimaryImageTag": "string",
|
||||
"SeriesPrimaryImageTag": "string",
|
||||
"AlbumArtist": "string",
|
||||
"AlbumArtists": [
|
||||
|
@ -4346,6 +4346,7 @@
|
||||
],
|
||||
"Album": "ALBUM",
|
||||
"AlbumId": "ALBUM-UUID",
|
||||
"AlbumPrimaryImageTag": "ALBUM-PRIMARY-IMAGE-TAG",
|
||||
"AlbumArtist": "Album Artist",
|
||||
"AlbumArtists": [
|
||||
{ "Name": "Album Artist", "Id": "9a65b2c222ddb34e51f5cae360fad3a1" }
|
||||
|
@ -302,8 +302,6 @@
|
||||
"Album": "string",
|
||||
"CollectionType": "string",
|
||||
"DisplayOrder": "string",
|
||||
"AlbumId": "21af9851-8e39-43a9-9c47-513d3b9e99fc",
|
||||
"AlbumPrimaryImageTag": "string",
|
||||
"SeriesPrimaryImageTag": "string",
|
||||
"AlbumArtist": "string",
|
||||
"AlbumArtists": [
|
||||
|
@ -1707,6 +1707,7 @@
|
||||
}),
|
||||
]),
|
||||
'AlbumId': 'ALBUM-UUID',
|
||||
'AlbumPrimaryImageTag': 'ALBUM-PRIMARY-IMAGE-TAG',
|
||||
'ArtistItems': list([
|
||||
dict({
|
||||
'Id': '1d864900526d9a9513b489f1cc28f8ca',
|
||||
|
@ -27,6 +27,7 @@ from homeassistant.components.media_player import (
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_ENTITY_PICTURE,
|
||||
ATTR_FRIENDLY_NAME,
|
||||
ATTR_ICON,
|
||||
)
|
||||
@ -124,6 +125,10 @@ async def test_media_player_music(
|
||||
assert state.attributes.get(ATTR_MEDIA_SERIES_TITLE) is None
|
||||
assert state.attributes.get(ATTR_MEDIA_SEASON) is None
|
||||
assert state.attributes.get(ATTR_MEDIA_EPISODE) is None
|
||||
assert (
|
||||
state.attributes.get(ATTR_ENTITY_PICTURE)
|
||||
== "http://localhost/Items/ALBUM-UUID/Images/Primary.jpg"
|
||||
)
|
||||
|
||||
entry = entity_registry.async_get(state.entity_id)
|
||||
assert entry
|
||||
|
Loading…
x
Reference in New Issue
Block a user