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.
This commit is contained in:
Odd Stråbø 2022-12-30 03:16:57 +01:00
parent 39f4ff0450
commit 8134dd0368
1 changed files with 7 additions and 1 deletions

View File

@ -79,6 +79,12 @@ class MusicVideos(KodiDb):
update = False update = False
LOG.info("MvideoId %s missing from kodi. repairing the entry.", obj['MvideoId']) 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['Path'] = API.get_file_path(obj['Path'])
obj['LibraryId'] = self.library['Id'] obj['LibraryId'] = self.library['Id']
obj['LibraryName'] = self.library['Name'] obj['LibraryName'] = self.library['Name']
@ -91,7 +97,7 @@ class MusicVideos(KodiDb):
obj['PlayCount'] = API.get_playcount(obj['Played'], obj['PlayCount']) obj['PlayCount'] = API.get_playcount(obj['Played'], obj['PlayCount'])
obj['Resume'] = API.adjust_resume((obj['Resume'] or 0) / 10000000.0) obj['Resume'] = API.adjust_resume((obj['Resume'] or 0) / 10000000.0)
obj['Runtime'] = round(float((obj['Runtime'] or 0) / 10000000.0), 6) 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['Genre'] = " / ".join(obj['Genres'])
obj['Studio'] = " / ".join(obj['Studios']) obj['Studio'] = " / ".join(obj['Studios'])
obj['Artists'] = " / ".join(obj['Artists'] or []) obj['Artists'] = " / ".join(obj['Artists'] or [])