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)
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)

View file

@ -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()