1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04:00

Fixes for TVDB and TVRage API search issues.

This commit is contained in:
echel0n 2014-06-07 17:43:58 -07:00
parent 1f180a5a05
commit 97a1693abf
2 changed files with 22 additions and 7 deletions

View File

@ -602,7 +602,11 @@ class Tvdb:
except zipfile.BadZipfile: except zipfile.BadZipfile:
raise tvdb_error("Bad zip file received from thetvdb.com, could not read it") raise tvdb_error("Bad zip file received from thetvdb.com, could not read it")
else: else:
return xmltodict.parse(resp.content.strip().encode('utf-8'), postprocessor=process) try:
return xmltodict.parse(resp.content.strip().encode('utf-8'), postprocessor=process)
except:
return xmltodict.parse(resp.content.strip(), postprocessor=process)
def _getetsrc(self, url, params=None, language=None): def _getetsrc(self, url, params=None, language=None):
"""Loads a URL using caching, returns an ElementTree of the source """Loads a URL using caching, returns an ElementTree of the source
@ -855,7 +859,11 @@ class Tvdb:
epsEt = self._getetsrc(url, language=language) epsEt = self._getetsrc(url, language=language)
for cur_ep in epsEt["episode"]: episodes = epsEt["episode"]
if not isinstance(episodes, list):
episodes = [episodes]
for cur_ep in episodes:
if self.config['dvdorder']: if self.config['dvdorder']:
log().debug('Using DVD ordering.') log().debug('Using DVD ordering.')
use_dvd = cur_ep['dvd_season'] != None and cur_ep['dvd_episodenumber'] != None use_dvd = cur_ep['dvd_season'] != None and cur_ep['dvd_episodenumber'] != None

View File

@ -390,7 +390,7 @@ class TVRage:
return os.path.join(tempfile.gettempdir(), "tvrage_api-%s" % (uid)) return os.path.join(tempfile.gettempdir(), "tvrage_api-%s" % (uid))
@retry(tvrage_error) #@retry(tvrage_error)
def _loadUrl(self, url, params=None): def _loadUrl(self, url, params=None):
try: try:
log().debug("Retrieving URL %s" % url) log().debug("Retrieving URL %s" % url)
@ -462,7 +462,10 @@ class TVRage:
return (key, value) return (key, value)
if resp.ok: if resp.ok:
return xmltodict.parse(resp.content.strip().encode('utf-8'), postprocessor=remap_keys) try:
return xmltodict.parse(resp.content.strip().encode('utf-8'), postprocessor=remap_keys)
except:
return xmltodict.parse(resp.content.strip(), postprocessor=remap_keys)
def _getetsrc(self, url, params=None): def _getetsrc(self, url, params=None):
"""Loads a URL using caching, returns an ElementTree of the source """Loads a URL using caching, returns an ElementTree of the source
@ -598,13 +601,17 @@ class TVRage:
self.config['params_epInfo']['sid'] = sid self.config['params_epInfo']['sid'] = sid
epsEt = self._getetsrc(self.config['url_epInfo'], self.config['params_epInfo']) epsEt = self._getetsrc(self.config['url_epInfo'], self.config['params_epInfo'])
for season in epsEt['episodelist'].values(): seasons = epsEt['episodelist']['season']
episodes = season['episode'] if not isinstance(seasons, list):
seasons = [seasons]
for season in seasons:
seas_no = int(season['@no'])
episodes = season['episode']
if not isinstance(episodes, list): if not isinstance(episodes, list):
episodes = [episodes] episodes = [episodes]
for episode in episodes: for episode in episodes:
seas_no = int(season['@no'])
ep_no = int(episode['episodenumber']) ep_no = int(episode['episodenumber'])
self._setItem(sid, seas_no, ep_no, 'seasonnumber', seas_no) self._setItem(sid, seas_no, ep_no, 'seasonnumber', seas_no)