forked from platypush/platypush
[jellyfin
] Added duration
field to video results.
This commit is contained in:
parent
d1b721dba5
commit
e66ca105d7
1 changed files with 13 additions and 0 deletions
|
@ -74,6 +74,7 @@ class JellyfinCollectionSchema(JellyfinSchema, MediaCollectionSchema):
|
|||
|
||||
|
||||
class JellyfinVideoSchema(JellyfinSchema, MediaVideoSchema):
|
||||
duration = fields.Number(attribute='RunTimeTicks')
|
||||
community_rating = fields.Number(attribute='CommunityRating')
|
||||
critic_rating = fields.Number(attribute='CriticRating')
|
||||
|
||||
|
@ -82,6 +83,18 @@ class JellyfinVideoSchema(JellyfinSchema, MediaVideoSchema):
|
|||
self.fields['year'].attribute = 'ProductionYear'
|
||||
self.fields['has_subtitles'].attribute = 'HasSubtitles'
|
||||
|
||||
@post_dump
|
||||
def _normalize_community_rating(self, data: dict, **_) -> dict:
|
||||
if data.get('community_rating'):
|
||||
data['community_rating'] *= 10
|
||||
return data
|
||||
|
||||
@post_dump
|
||||
def _normalize_duration(self, data: dict, **_) -> dict:
|
||||
if data.get('duration'):
|
||||
data['duration'] //= 1e7
|
||||
return data
|
||||
|
||||
|
||||
class JellyfinMovieSchema(JellyfinVideoSchema):
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue