Fixed issue that was causing malformed dates for shows, now SB will smartly set the date even if one didn't exist so that we don't just toss the episode away so long as we have enough data to satisfiy us.

This commit is contained in:
echel0n 2014-03-16 06:33:00 -07:00
parent 146d9ba23b
commit 5cd7ad2afb
2 changed files with 8 additions and 12 deletions

View file

@ -398,13 +398,13 @@ class TVRage:
elm.tag = robj.sub(lambda m: reDict[m.group(0)], elm.tag) elm.tag = robj.sub(lambda m: reDict[m.group(0)], elm.tag)
if elm.tag in 'firstaired': if elm.tag in 'firstaired':
if elm.text is "0000-00-00":
elm.text = str(dt.date.fromordinal(1))
try: 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() fixDate = parse(elm.text, fuzzy=True).date()
elm.text = fixDate.strftime("%Y-%m-%d") elm.text = fixDate.strftime("%Y-%m-%d")
except: except:
pass continue
return ElementTree.fromstring(ElementTree.tostring(xml)) return ElementTree.fromstring(ElementTree.tostring(xml))
except SyntaxError: except SyntaxError:
src = self._loadUrl(url, params) src = self._loadUrl(url, params)

View file

@ -1348,13 +1348,10 @@ class TVEpisode(object):
self.description = getattr(myEp, 'overview', "") self.description = getattr(myEp, 'overview', "")
try: try:
firstaired = "0000-00-00" firstaired = getattr(myEp, 'firstaired', None)
if getattr(myEp, 'firstaired', None) is not None: if firstaired is None: raise ValueError
firstaired = myEp['firstaired']
if firstaired is "0000-00-00":
firstaired = str(datetime.date.fromordinal(1))
firstaired = re.sub("(0{4})([-]0{2}){1,}", str(datetime.date.fromordinal(1)), firstaired)
rawAirdate = [int(x) for x in firstaired.split("-")] rawAirdate = [int(x) for x in firstaired.split("-")]
self.airdate = datetime.date(rawAirdate[0], rawAirdate[1], rawAirdate[2]) self.airdate = datetime.date(rawAirdate[0], rawAirdate[1], rawAirdate[2])
except ValueError: except ValueError:
@ -1365,9 +1362,8 @@ class TVEpisode(object):
return False return False
#early conversion to int so that episode doesn't get marked dirty #early conversion to int so that episode doesn't get marked dirty
if getattr(myEp, 'id', None) is not None: self.indexerid = getattr(myEp, 'id', None)
self.indexerid = int(myEp['id']) if self.indexerid is None:
else:
logger.log(u"Failed to retrieve ID from " + self.indexer, logger.ERROR) logger.log(u"Failed to retrieve ID from " + self.indexer, logger.ERROR)
if self.indexerid != -1: if self.indexerid != -1:
self.deleteEpisode() self.deleteEpisode()