diff --git a/platypush/plugins/media/jellyfin/__init__.py b/platypush/plugins/media/jellyfin/__init__.py index ca338f7a3b..6a7b5f5238 100644 --- a/platypush/plugins/media/jellyfin/__init__.py +++ b/platypush/plugins/media/jellyfin/__init__.py @@ -7,6 +7,7 @@ from platypush.plugins import Plugin, action from platypush.schemas.media.jellyfin import ( JellyfinAlbumSchema, JellyfinArtistSchema, + JellyfinBookSchema, JellyfinCollectionSchema, JellyfinEpisodeSchema, JellyfinMovieSchema, @@ -158,6 +159,8 @@ class MediaJellyfinPlugin(Plugin): 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 d5b52974c7..bf66f3556e 100644 --- a/platypush/schemas/media/jellyfin.py +++ b/platypush/schemas/media/jellyfin.py @@ -294,3 +294,22 @@ class JellyfinPhotoSchema(JellyfinSchema): ) 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