[jellyfin] Added duration field to video results.

This commit is contained in:
Fabio Manganiello 2023-11-08 22:34:26 +01:00
parent d1b721dba5
commit e66ca105d7
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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