mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Use kodi posters, fall back to thumbnails if unavailable. (#144066)
This commit is contained in:
parent
fb94f8ea18
commit
30e4264aa9
@ -152,7 +152,10 @@ async def item_payload(item, get_thumbnail_url=None):
|
||||
_LOGGER.debug("Unknown media type received: %s", media_content_type)
|
||||
raise UnknownMediaType from err
|
||||
|
||||
thumbnail = item.get("thumbnail")
|
||||
if "art" in item:
|
||||
thumbnail = item["art"].get("poster", item.get("thumbnail"))
|
||||
else:
|
||||
thumbnail = item.get("thumbnail")
|
||||
if thumbnail is not None and get_thumbnail_url is not None:
|
||||
thumbnail = await get_thumbnail_url(
|
||||
media_content_type, media_content_id, thumbnail_url=thumbnail
|
||||
@ -237,14 +240,16 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
title = None
|
||||
media = None
|
||||
|
||||
properties = ["thumbnail"]
|
||||
properties = ["thumbnail", "art"]
|
||||
if search_type == MediaType.ALBUM:
|
||||
if search_id:
|
||||
album = await media_library.get_album_details(
|
||||
album_id=int(search_id), properties=properties
|
||||
)
|
||||
thumbnail = media_library.thumbnail_url(
|
||||
album["albumdetails"].get("thumbnail")
|
||||
album["albumdetails"]["art"].get(
|
||||
"poster", album["albumdetails"].get("thumbnail")
|
||||
)
|
||||
)
|
||||
title = album["albumdetails"]["label"]
|
||||
media = await media_library.get_songs(
|
||||
@ -256,6 +261,7 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
"album",
|
||||
"thumbnail",
|
||||
"track",
|
||||
"art",
|
||||
],
|
||||
)
|
||||
media = media.get("songs")
|
||||
@ -274,7 +280,9 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
artist_id=int(search_id), properties=properties
|
||||
)
|
||||
thumbnail = media_library.thumbnail_url(
|
||||
artist["artistdetails"].get("thumbnail")
|
||||
artist["artistdetails"]["art"].get(
|
||||
"poster", artist["artistdetails"].get("thumbnail")
|
||||
)
|
||||
)
|
||||
title = artist["artistdetails"]["label"]
|
||||
else:
|
||||
@ -293,9 +301,10 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
movie_id=int(search_id), properties=properties
|
||||
)
|
||||
thumbnail = media_library.thumbnail_url(
|
||||
movie["moviedetails"].get("thumbnail")
|
||||
movie["moviedetails"]["art"].get(
|
||||
"poster", movie["moviedetails"].get("thumbnail")
|
||||
)
|
||||
)
|
||||
title = movie["moviedetails"]["label"]
|
||||
else:
|
||||
media = await media_library.get_movies(properties)
|
||||
media = media.get("movies")
|
||||
@ -305,14 +314,16 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
if search_id:
|
||||
media = await media_library.get_seasons(
|
||||
tv_show_id=int(search_id),
|
||||
properties=["thumbnail", "season", "tvshowid"],
|
||||
properties=["thumbnail", "season", "tvshowid", "art"],
|
||||
)
|
||||
media = media.get("seasons")
|
||||
tvshow = await media_library.get_tv_show_details(
|
||||
tv_show_id=int(search_id), properties=properties
|
||||
)
|
||||
thumbnail = media_library.thumbnail_url(
|
||||
tvshow["tvshowdetails"].get("thumbnail")
|
||||
tvshow["tvshowdetails"]["art"].get(
|
||||
"poster", tvshow["tvshowdetails"].get("thumbnail")
|
||||
)
|
||||
)
|
||||
title = tvshow["tvshowdetails"]["label"]
|
||||
else:
|
||||
@ -325,7 +336,7 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
media = await media_library.get_episodes(
|
||||
tv_show_id=int(tv_show_id),
|
||||
season_id=int(season_id),
|
||||
properties=["thumbnail", "tvshowid", "seasonid"],
|
||||
properties=["thumbnail", "tvshowid", "seasonid", "art"],
|
||||
)
|
||||
media = media.get("episodes")
|
||||
if media:
|
||||
@ -333,7 +344,9 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
season_id=int(media[0]["seasonid"]), properties=properties
|
||||
)
|
||||
thumbnail = media_library.thumbnail_url(
|
||||
season["seasondetails"].get("thumbnail")
|
||||
season["seasondetails"]["art"].get(
|
||||
"poster", season["seasondetails"].get("thumbnail")
|
||||
)
|
||||
)
|
||||
title = season["seasondetails"]["label"]
|
||||
|
||||
@ -343,6 +356,7 @@ async def get_media_info(media_library, search_id, search_type):
|
||||
properties=["thumbnail", "channeltype", "channel", "broadcastnow"],
|
||||
)
|
||||
media = media.get("channels")
|
||||
|
||||
title = "Channels"
|
||||
|
||||
return thumbnail, title, media
|
||||
|
Loading…
x
Reference in New Issue
Block a user