From 8134dd03688131a25507d60563002eae6f544504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= Date: Fri, 30 Dec 2022 03:16:57 +0100 Subject: [PATCH] Fix syncing of musicvideos with production year YYYYmmdd Be more lenient towards garbage metadata Jellyfin some times puts the full YYYYmmdd in the year field. --- jellyfin_kodi/objects/musicvideos.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jellyfin_kodi/objects/musicvideos.py b/jellyfin_kodi/objects/musicvideos.py index 0d80dccd..32f76967 100644 --- a/jellyfin_kodi/objects/musicvideos.py +++ b/jellyfin_kodi/objects/musicvideos.py @@ -79,6 +79,12 @@ class MusicVideos(KodiDb): update = False LOG.info("MvideoId %s missing from kodi. repairing the entry.", obj['MvideoId']) + if (obj.get('ProductionYear') or 0) > 9999: + obj['ProductionYear'] = int(str(obj['ProductionYear'])[:4]) + + if (obj.get('Year') or 0) > 9999: + obj['Year'] = int(str(obj['Year'])[:4]) + obj['Path'] = API.get_file_path(obj['Path']) obj['LibraryId'] = self.library['Id'] obj['LibraryName'] = self.library['Name'] @@ -91,7 +97,7 @@ class MusicVideos(KodiDb): obj['PlayCount'] = API.get_playcount(obj['Played'], obj['PlayCount']) obj['Resume'] = API.adjust_resume((obj['Resume'] or 0) / 10000000.0) obj['Runtime'] = round(float((obj['Runtime'] or 0) / 10000000.0), 6) - obj['Premiere'] = Local(obj['Premiere']) if obj['Premiere'] else datetime.date(obj['Year'] or 2021, 1, 1) + obj['Premiere'] = Local(obj['Premiere']) if obj['Premiere'] else datetime.date(obj['Year'] or 1970, 1, 1) obj['Genre'] = " / ".join(obj['Genres']) obj['Studio'] = " / ".join(obj['Studios']) obj['Artists'] = " / ".join(obj['Artists'] or [])