From 78779d01d759278dec66b049366c8616c133d489 Mon Sep 17 00:00:00 2001 From: Jamie Osborne Date: Wed, 20 Dec 2017 17:35:19 +0000 Subject: [PATCH] Don't use current date to fill missing day/month --- Contents/Code/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 192371a..6d52517 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -5,6 +5,9 @@ import Queue import json +import datetime +from dateutil import parser + #from mutagen import File #from mutagen.mp4 import MP4 #from mutagen.id3 import ID3 @@ -137,7 +140,9 @@ def Log(self, message, *args): def getDateFromString(self, string): try: - return Datetime.ParseDate(string).date() + if not len(string): return None + DEFAULT_DATE = datetime.datetime(datetime.MINYEAR, 1, 1) + return parser.parse(string, default=DEFAULT_DATE).date() except: return None @@ -237,7 +242,9 @@ def Log(self, message, *args): def getDateFromString(self, string): try: - return Datetime.ParseDate(string).date() + if not len(string): return None + DEFAULT_DATE = datetime.datetime(datetime.MINYEAR, 1, 1) + return parser.parse(string, default=DEFAULT_DATE).date() except: return None