Fix for firstaired dates as they are inconsistant in format on TVRage

This commit is contained in:
echel0n 2014-03-10 17:28:28 -07:00
parent f6e3ee1ef2
commit 33cf136487
1 changed files with 7 additions and 2 deletions

View File

@ -576,8 +576,13 @@ class TVRage:
tag = curInfo.tag.lower()
if curInfo.tag.lower() in ('started', 'ended') and curInfo.text is not None:
fixDate = dt.datetime.strptime(curInfo.text,"%b/%d/%Y")
value = fixDate.strftime("%Y-%m-%d")
try:
fixDate = dt.datetime.strptime(curInfo.text,"%b/%Y")
newDate = fixDate.replace(day=01)
value = newDate.strftime("%Y-%m-%d")
except Exception:
fixDate = dt.datetime.strptime(curInfo.text,"%b/%d/%Y")
value = fixDate.strftime("%Y-%m-%d")
else:
value = curInfo.text