From 3e61bd7a9bf86e6fc1e475906a8532cc989574a2 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 15 Oct 2024 23:24:59 +0200 Subject: [PATCH] [media.jellyfin] Several improvements on schema definitions. --- platypush/schemas/media/jellyfin.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/platypush/schemas/media/jellyfin.py b/platypush/schemas/media/jellyfin.py index 99efd560ce..d5b52974c7 100644 --- a/platypush/schemas/media/jellyfin.py +++ b/platypush/schemas/media/jellyfin.py @@ -11,6 +11,8 @@ logger = logging.getLogger(__name__) class JellyfinSchema(Schema): + can_delete = fields.Boolean(attribute='CanDelete') + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if 'id' in self.fields: @@ -133,12 +135,6 @@ class JellyfinTrackSchema(JellyfinSchema): data['community_rating'] *= 10 return data - @post_dump - def _normalize_duration(self, data: dict, **_) -> dict: - if data.get('duration'): - data['duration'] //= 1e7 - return data - @post_dump def _add_title(self, data: dict, **_) -> dict: if not data.get('title'): @@ -185,7 +181,6 @@ class JellyfinCollectionSchema(JellyfinSchema, MediaCollectionSchema): class JellyfinVideoSchema(JellyfinSchema, MediaVideoSchema): type = fields.Constant('video') item_type = fields.Constant('video') - path = fields.String(attribute='Path') duration = fields.Number(attribute='RunTimeTicks') community_rating = fields.Number(attribute='CommunityRating') container = fields.String( @@ -196,7 +191,6 @@ class JellyfinVideoSchema(JellyfinSchema, MediaVideoSchema): }, ) critic_rating = fields.Number(attribute='CriticRating') - created_at = DateTime(attribute='DateCreated') imdb_url = fields.URL( attribute='ExternalUrl', metadata={ @@ -214,6 +208,7 @@ class JellyfinVideoSchema(JellyfinSchema, MediaVideoSchema): super().__init__(*args, **kwargs) self.fields['year'].attribute = 'ProductionYear' self.fields['has_subtitles'].attribute = 'HasSubtitles' + self.fields['created_at'].attribute = 'DateCreated' @post_dump def _normalize_community_rating(self, data: dict, **_) -> dict: @@ -221,12 +216,6 @@ class JellyfinVideoSchema(JellyfinSchema, MediaVideoSchema): data['community_rating'] *= 10 return data - @post_dump - def _normalize_duration(self, data: dict, **_) -> dict: - if data.get('duration'): - data['duration'] //= 1e7 - return data - @pre_dump def _extract_imdb_url(self, data: dict, **_) -> dict: external_urls = data.get('ExternalUrls', [])