diff --git a/platypush/schemas/media/jellyfin.py b/platypush/schemas/media/jellyfin.py index 125b007bd8..c4fba21e2b 100644 --- a/platypush/schemas/media/jellyfin.py +++ b/platypush/schemas/media/jellyfin.py @@ -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