From e66ca105d7d885373ec0e43f1652bab57c652ddf Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 8 Nov 2023 22:34:26 +0100 Subject: [PATCH] [`jellyfin`] Added `duration` field to video results. --- platypush/schemas/media/jellyfin.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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