From 30e4264aa9d987d09e65dcb4360f99a26ca9f500 Mon Sep 17 00:00:00 2001 From: Charlie Rusbridger Date: Sat, 3 May 2025 20:10:33 +0100 Subject: [PATCH] Use kodi posters, fall back to thumbnails if unavailable. (#144066) --- homeassistant/components/kodi/browse_media.py | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/kodi/browse_media.py b/homeassistant/components/kodi/browse_media.py index 60e99d98cb1..3873f385881 100644 --- a/homeassistant/components/kodi/browse_media.py +++ b/homeassistant/components/kodi/browse_media.py @@ -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