From 33cf136487247b96c29af19ec6b132bfa6dcf2d5 Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 10 Mar 2014 17:28:28 -0700 Subject: [PATCH] Fix for firstaired dates as they are inconsistant in format on TVRage --- lib/tvrage_api/tvrage_api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/tvrage_api/tvrage_api.py b/lib/tvrage_api/tvrage_api.py index 0efce1dc..e595af81 100644 --- a/lib/tvrage_api/tvrage_api.py +++ b/lib/tvrage_api/tvrage_api.py @@ -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