From adf6728f142378d1b3b2c81acae21d02858d6de3 Mon Sep 17 00:00:00 2001 From: Wulf Rajek <40003252+AnonTester@users.noreply.github.com> Date: Tue, 12 Apr 2022 00:22:05 +0100 Subject: [PATCH] Gracefully deal with incorrect dates --- cps/editbooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cps/editbooks.py b/cps/editbooks.py index db87d891..b14f79e0 100755 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -983,9 +983,9 @@ def create_book_on_upload(modify_date, meta): # combine path and normalize path from Windows systems path = os.path.join(author_dir, title_dir).replace('\\', '/') - if meta.pubdate != "": + try: pubdate = datetime.strptime(meta.pubdate[:10], "%Y-%m-%d") - else: + except: pubdate = datetime(101, 1, 1) # Calibre adds books with utc as timezone