From 25c619032f75863a90412e747a17012a58b8e57e Mon Sep 17 00:00:00 2001 From: Simone Pierazzini Date: Fri, 26 Jul 2019 12:11:00 +0200 Subject: [PATCH] Do not fail while parsing illegal dates. Return None instead. --- plexapi/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plexapi/utils.py b/plexapi/utils.py index 531e406a..4f8ef01c 100644 --- a/plexapi/utils.py +++ b/plexapi/utils.py @@ -176,7 +176,11 @@ def toDatetime(value, format=None): """ if value and value is not None: if format: - value = datetime.strptime(value, format) + try: + value = datetime.strptime(value, format) + except ValueError: + # parsing failed + return None else: # https://bugs.python.org/issue30684 # And platform support for before epoch seems to be flaky.