From 5c93a06e9b6842797420d58982c1d4df69cd6b13 Mon Sep 17 00:00:00 2001 From: Abby Gourlay Date: Sun, 15 Mar 2020 01:27:07 +0000 Subject: [PATCH] Added mitigation for #216 for when the year data from the server is invalid --- jellyfin_kodi/downloader.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jellyfin_kodi/downloader.py b/jellyfin_kodi/downloader.py index fc3a1125..2f034f03 100644 --- a/jellyfin_kodi/downloader.py +++ b/jellyfin_kodi/downloader.py @@ -282,6 +282,17 @@ def _get_items(query, server_id=None): query['params'] = params result = result or {'Items': []} + + # Mitigates #216 till the server validates the date provided is valid + for count in range(0, len(result["Items"])): + if result["Items"][count].get('ProductionYear'): + try: + from datetime import date + date(result["Items"][count]["ProductionYear"], 1, 1) + except ValueError: + LOG.info("#216 mitigation triggered. Setting ProductionYear to None") + result["Items"][count]["ProductionYear"] = None + items['Items'].extend(result['Items']) # Using items to return data and communicate a restore point back to the callee is # a violation of the SRP. TODO: Seperate responsibilities.