From 825593a445bb36c91632af8be606d0bcb59bcb76 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 20 Oct 2024 02:35:19 +0200 Subject: [PATCH] [#414] Support for Jellyfin book items [backend]. --- platypush/plugins/media/jellyfin/__init__.py | 3 +++ platypush/schemas/media/jellyfin.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/platypush/plugins/media/jellyfin/__init__.py b/platypush/plugins/media/jellyfin/__init__.py index ca338f7a3..6a7b5f523 100644 --- a/platypush/plugins/media/jellyfin/__init__.py +++ b/platypush/plugins/media/jellyfin/__init__.py @@ -7,6 +7,7 @@ from platypush.schemas.media.jellyfin import ( JellyfinAlbumSchema, JellyfinArtistSchema, + JellyfinBookSchema, JellyfinCollectionSchema, JellyfinEpisodeSchema, JellyfinMovieSchema, @@ -158,6 +159,8 @@ def _serialize_search_results(self, search_results: Iterable[dict]) -> List[dict result = JellyfinVideoSchema().dump(result) elif result['Type'] == 'Photo': result = JellyfinPhotoSchema().dump(result) + elif result['Type'] == 'Book': + result = JellyfinBookSchema().dump(result) elif result['Type'] == 'Episode': result = JellyfinEpisodeSchema().dump(result) elif result['Type'] == 'Audio': diff --git a/platypush/schemas/media/jellyfin.py b/platypush/schemas/media/jellyfin.py index d5b52974c..bf66f3556 100644 --- a/platypush/schemas/media/jellyfin.py +++ b/platypush/schemas/media/jellyfin.py @@ -294,3 +294,22 @@ def _gen_photo_url(self, data, **_): ) data['url'] = f'{base_url}/Download?api_key={self._api_key}' return data + + +class JellyfinBookSchema(JellyfinSchema): + id = fields.String(attribute='Id') + name = fields.String(attribute='Name') + url = fields.URL() + embed_url = fields.URL() + type = fields.Constant('book') + item_type = fields.Constant('book') + path = fields.String(attribute='Path') + + @pre_dump + def _gen_book_url(self, data, **_): + data = data or {} + data[ + 'url' + ] = f'{self._server}/Items/{data["Id"]}/Download?api_key={self._api_key}' + data['embed_url'] = f'{self._server}/web/#/details?id={data["Id"]}' + return data