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