diff --git a/lib/tvrage_api/tvrage_api.py b/lib/tvrage_api/tvrage_api.py index 5405d5c0..3aab1e3b 100644 --- a/lib/tvrage_api/tvrage_api.py +++ b/lib/tvrage_api/tvrage_api.py @@ -398,13 +398,13 @@ class TVRage: elm.tag = robj.sub(lambda m: reDict[m.group(0)], elm.tag) if elm.tag in 'firstaired': - if elm.text is "0000-00-00": - elm.text = str(dt.date.fromordinal(1)) try: + elm.text = re.sub("(0{4})([-]0{2}){1,}", str(dt.date.fromordinal(1)), elm.text) + elm.text = re.sub("([-]0{2}){1,}", "", elm.text) fixDate = parse(elm.text, fuzzy=True).date() elm.text = fixDate.strftime("%Y-%m-%d") except: - pass + continue return ElementTree.fromstring(ElementTree.tostring(xml)) except SyntaxError: src = self._loadUrl(url, params) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 419791ad..409c9f5f 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1348,13 +1348,10 @@ class TVEpisode(object): self.description = getattr(myEp, 'overview', "") try: - firstaired = "0000-00-00" - if getattr(myEp, 'firstaired', None) is not None: - firstaired = myEp['firstaired'] - - if firstaired is "0000-00-00": - firstaired = str(datetime.date.fromordinal(1)) + firstaired = getattr(myEp, 'firstaired', None) + if firstaired is None: raise ValueError + firstaired = re.sub("(0{4})([-]0{2}){1,}", str(datetime.date.fromordinal(1)), firstaired) rawAirdate = [int(x) for x in firstaired.split("-")] self.airdate = datetime.date(rawAirdate[0], rawAirdate[1], rawAirdate[2]) except ValueError: @@ -1365,9 +1362,8 @@ class TVEpisode(object): return False #early conversion to int so that episode doesn't get marked dirty - if getattr(myEp, 'id', None) is not None: - self.indexerid = int(myEp['id']) - else: + self.indexerid = getattr(myEp, 'id', None) + if self.indexerid is None: logger.log(u"Failed to retrieve ID from " + self.indexer, logger.ERROR) if self.indexerid != -1: self.deleteEpisode()