mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-07 11:58:01 -05:00
Bugfix for TVRage search by name, fixed issue with dates and key names
This commit is contained in:
parent
0fcd780c2f
commit
75c8acc6d4
@ -431,8 +431,9 @@ class TVRage:
|
|||||||
reDict = {
|
reDict = {
|
||||||
'showid': 'id',
|
'showid': 'id',
|
||||||
'showname': 'seriesname',
|
'showname': 'seriesname',
|
||||||
|
'name': 'seriesname',
|
||||||
'summary': 'overview',
|
'summary': 'overview',
|
||||||
'startdate': 'firstaired',
|
'started': 'firstaired',
|
||||||
'genres': 'genre',
|
'genres': 'genre',
|
||||||
'airtime': 'airs_time',
|
'airtime': 'airs_time',
|
||||||
'airday': 'airs_dayofweek',
|
'airday': 'airs_dayofweek',
|
||||||
@ -453,6 +454,22 @@ class TVRage:
|
|||||||
tree = ElementTree.ElementTree(xml)
|
tree = ElementTree.ElementTree(xml)
|
||||||
for elm in tree.iter():
|
for elm in tree.iter():
|
||||||
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':
|
||||||
|
try:
|
||||||
|
fixDate = dt.datetime.strptime(elm.text,"%b/%d/%Y")
|
||||||
|
value = fixDate.strftime("%Y-%m-%d")
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
fixDate = dt.datetime.strptime(elm.text,"%b/%Y")
|
||||||
|
newDate = fixDate.replace(day=01)
|
||||||
|
value = newDate.strftime("%Y-%m-%d")
|
||||||
|
except:
|
||||||
|
fixDate = dt.datetime.strptime(elm.text,"%Y")
|
||||||
|
newDate = fixDate.replace(month=01, day=01)
|
||||||
|
value = newDate.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
elm.text = value
|
||||||
return ElementTree.fromstring(ElementTree.tostring(xml))
|
return ElementTree.fromstring(ElementTree.tostring(xml))
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
src = self._loadUrl(url, recache=True)
|
src = self._loadUrl(url, recache=True)
|
||||||
@ -461,7 +478,23 @@ class TVRage:
|
|||||||
tree = ElementTree.ElementTree(xml)
|
tree = ElementTree.ElementTree(xml)
|
||||||
for elm in tree.iter():
|
for elm in tree.iter():
|
||||||
elm.tag = robj.sub(lambda m: reDict[m.group(0)], elm.tag)
|
elm.tag = robj.sub(lambda m: reDict[m.group(0)], elm.tag)
|
||||||
return ElementTree.fromstring(ElementTree.tostring(xml))
|
|
||||||
|
if elm.tag in 'firstaired':
|
||||||
|
try:
|
||||||
|
fixDate = dt.datetime.strptime(elm.text,"%b/%d/%Y")
|
||||||
|
value = fixDate.strftime("%Y-%m-%d")
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
fixDate = dt.datetime.strptime(elm.text,"%b/%Y")
|
||||||
|
newDate = fixDate.replace(day=01)
|
||||||
|
value = newDate.strftime("%Y-%m-%d")
|
||||||
|
except:
|
||||||
|
fixDate = dt.datetime.strptime(elm.text,"%Y")
|
||||||
|
newDate = fixDate.replace(month=01, day=01)
|
||||||
|
value = newDate.strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
elm.text = value
|
||||||
|
return ElementTree.fromstring(ElementTree.tostring(xml))
|
||||||
except SyntaxError, exceptionmsg:
|
except SyntaxError, exceptionmsg:
|
||||||
errormsg = "There was an error with the XML retrieved from tvrage.com:\n%s" % (
|
errormsg = "There was an error with the XML retrieved from tvrage.com:\n%s" % (
|
||||||
exceptionmsg
|
exceptionmsg
|
||||||
@ -570,22 +603,7 @@ class TVRage:
|
|||||||
|
|
||||||
for curInfo in seriesInfoEt:
|
for curInfo in seriesInfoEt:
|
||||||
tag = curInfo.tag.lower()
|
tag = curInfo.tag.lower()
|
||||||
|
value = curInfo.text
|
||||||
if tag in 'firstaired':
|
|
||||||
try:
|
|
||||||
fixDate = dt.datetime.strptime(curInfo.text,"%b/%d/%Y")
|
|
||||||
value = fixDate.strftime("%Y-%m-%d")
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
fixDate = dt.datetime.strptime(curInfo.text,"%b/%Y")
|
|
||||||
newDate = fixDate.replace(day=01)
|
|
||||||
value = newDate.strftime("%Y-%m-%d")
|
|
||||||
except:
|
|
||||||
fixDate = dt.datetime.strptime(curInfo.text,"%Y")
|
|
||||||
newDate = fixDate.replace(month=01, day=01)
|
|
||||||
value = newDate.strftime("%Y-%m-%d")
|
|
||||||
else:
|
|
||||||
value = curInfo.text
|
|
||||||
|
|
||||||
if value is not None:
|
if value is not None:
|
||||||
value = self._cleanData(value)
|
value = self._cleanData(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user