Skip to content

Commit

Permalink
[#414] Support for Jellyfin book items [backend].
Browse files Browse the repository at this point in the history
  • Loading branch information
blacklight committed Oct 20, 2024
1 parent ec8fe40 commit 825593a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions platypush/plugins/media/jellyfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from platypush.schemas.media.jellyfin import (
JellyfinAlbumSchema,
JellyfinArtistSchema,
JellyfinBookSchema,
JellyfinCollectionSchema,
JellyfinEpisodeSchema,
JellyfinMovieSchema,
Expand Down Expand Up @@ -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':
Expand Down
19 changes: 19 additions & 0 deletions platypush/schemas/media/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 825593a

Please sign in to comment.