From b3662cfb7b79668b906ca918cc5adf27b9564223 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 21 Mar 2014 04:09:18 -0700 Subject: [PATCH] Fixed bug with air dates being malformed --- sickbeard/tv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index a50917e6..af828063 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1358,12 +1358,12 @@ class TVEpisode(object): self.description = getattr(myEp, 'overview', "") - try: - firstaired = getattr(myEp, 'firstaired', None) - if firstaired is None: raise ValueError + firstaired = getattr(myEp, 'firstaired', None) + if firstaired is None or "0000-00-00": + firstaired = str(datetime.date.fromordinal(1)) + rawAirdate = [int(x) for x in firstaired.split("-")] - firstaired = re.sub("(0{4})([-]0{2}){1,}", str(datetime.date.fromordinal(1)), firstaired) - rawAirdate = [int(x) for x in firstaired.split("-")] + try: self.airdate = datetime.date(rawAirdate[0], rawAirdate[1], rawAirdate[2]) except ValueError: logger.log(u"Malformed air date retrieved from " + self.indexer + " ("+self.show.name+" - "+str(season)+"x"+str(episode)+")", logger.ERROR)