From 4c952f09aca57352c339c0111c31a069ab2311fa Mon Sep 17 00:00:00 2001 From: Jan Stienstra <65826735+j-stienstra@users.noreply.github.com> Date: Wed, 19 Jan 2022 15:13:11 +0100 Subject: [PATCH] Allow to skip artist level in media hierarchy (#64160) --- homeassistant/components/jellyfin/media_source.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/jellyfin/media_source.py b/homeassistant/components/jellyfin/media_source.py index 3eedc1b0440..22bb2b3937d 100644 --- a/homeassistant/components/jellyfin/media_source.py +++ b/homeassistant/components/jellyfin/media_source.py @@ -170,6 +170,9 @@ class JellyfinSource(MediaSource): if include_children: result.children_media_class = MEDIA_CLASS_ARTIST result.children = await self._build_artists(library_id) # type: ignore[assignment] + if not result.children: + result.children_media_class = MEDIA_CLASS_ALBUM + result.children = await self._build_albums(library_id) # type: ignore[assignment] return result @@ -204,9 +207,9 @@ class JellyfinSource(MediaSource): return result - async def _build_albums(self, artist_id: str) -> list[BrowseMediaSource]: + async def _build_albums(self, parent_id: str) -> list[BrowseMediaSource]: """Return all albums of a single artist as browsable media sources.""" - albums = await self._get_children(artist_id, ITEM_TYPE_ALBUM) + albums = await self._get_children(parent_id, ITEM_TYPE_ALBUM) albums = sorted(albums, key=lambda k: k[ITEM_KEY_NAME]) # type: ignore[no-any-return] return [await self._build_album(album, False) for album in albums]