mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Fixed a bug in TVRage API that was not properly handling datetime issues
This commit is contained in:
parent
75c8acc6d4
commit
82db6e9b54
1 changed files with 10 additions and 27 deletions
|
@ -28,8 +28,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import xml.etree.ElementTree as ElementTree
|
import xml.etree.ElementTree as ElementTree
|
||||||
|
|
||||||
from tvrage_cache import CacheHandler
|
from lib import requests
|
||||||
|
from lib.dateutil.parser import parse
|
||||||
|
|
||||||
|
from tvrage_cache import CacheHandler
|
||||||
from tvrage_ui import BaseUI
|
from tvrage_ui import BaseUI
|
||||||
from tvrage_exceptions import (tvrage_error, tvrage_userabort, tvrage_shownotfound,
|
from tvrage_exceptions import (tvrage_error, tvrage_userabort, tvrage_shownotfound,
|
||||||
tvrage_seasonnotfound, tvrage_episodenotfound, tvrage_attributenotfound)
|
tvrage_seasonnotfound, tvrage_episodenotfound, tvrage_attributenotfound)
|
||||||
|
@ -409,7 +411,8 @@ class TVRage:
|
||||||
global lastTimeout
|
global lastTimeout
|
||||||
try:
|
try:
|
||||||
log().debug("Retrieving URL %s" % url)
|
log().debug("Retrieving URL %s" % url)
|
||||||
resp = self.urlopener.open(url)
|
#resp = self.urlopener.open(url)
|
||||||
|
resp = requests.get(url)
|
||||||
if 'x-local-cache' in resp.headers:
|
if 'x-local-cache' in resp.headers:
|
||||||
log().debug("URL %s was cached in %s" % (
|
log().debug("URL %s was cached in %s" % (
|
||||||
url,
|
url,
|
||||||
|
@ -423,7 +426,7 @@ class TVRage:
|
||||||
lastTimeout = dt.datetime.now()
|
lastTimeout = dt.datetime.now()
|
||||||
raise tvrage_error("Could not connect to server: %s" % (errormsg))
|
raise tvrage_error("Could not connect to server: %s" % (errormsg))
|
||||||
|
|
||||||
return resp.read()
|
return resp.content
|
||||||
|
|
||||||
def _getetsrc(self, url):
|
def _getetsrc(self, url):
|
||||||
"""Loads a URL using caching, returns an ElementTree of the source
|
"""Loads a URL using caching, returns an ElementTree of the source
|
||||||
|
@ -456,18 +459,8 @@ 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':
|
||||||
try:
|
fixDate = parse(elm.text)
|
||||||
fixDate = dt.datetime.strptime(elm.text,"%b/%d/%Y")
|
value = fixDate.strftime("%Y-%m-%d")
|
||||||
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
|
elm.text = value
|
||||||
return ElementTree.fromstring(ElementTree.tostring(xml))
|
return ElementTree.fromstring(ElementTree.tostring(xml))
|
||||||
|
@ -480,18 +473,8 @@ 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':
|
||||||
try:
|
fixDate = parse(elm.text)
|
||||||
fixDate = dt.datetime.strptime(elm.text,"%b/%d/%Y")
|
value = fixDate.strftime("%Y-%m-%d")
|
||||||
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
|
elm.text = value
|
||||||
return ElementTree.fromstring(ElementTree.tostring(xml))
|
return ElementTree.fromstring(ElementTree.tostring(xml))
|
||||||
|
|
Loading…
Reference in a new issue