Change no longer fetch xml and zip and adjust code inline with library updates.

This commit is contained in:
JackDandy 2015-04-28 18:32:37 +01:00
parent 3ab45e19d5
commit 837265b6f6
4 changed files with 17 additions and 16 deletions

View file

@ -563,7 +563,7 @@ class Tvdb:
# get response from TVDB # get response from TVDB
if self.config['cache_enabled']: if self.config['cache_enabled']:
session = CacheControl(cache=caches.FileCache(self.config['cache_location'])) session = CacheControl(requests.session(), cache=caches.FileCache(self.config['cache_location']))
if self.config['proxy']: if self.config['proxy']:
log().debug("Using proxy for URL: %s" % url) log().debug("Using proxy for URL: %s" % url)
session.proxies = { session.proxies = {
@ -571,7 +571,7 @@ class Tvdb:
"https": self.config['proxy'], "https": self.config['proxy'],
} }
resp = session.get(url, cache_auto=True, params=params) resp = session.get(url, params=params)
else: else:
resp = requests.get(url, params=params) resp = requests.get(url, params=params)
except requests.exceptions.HTTPError, e: except requests.exceptions.HTTPError, e:
@ -836,15 +836,14 @@ class Tvdb:
# Parse show information # Parse show information
log().debug('Getting all series data for %s' % (sid)) log().debug('Getting all series data for %s' % (sid))
seriesInfoEt = self._getetsrc( url = self.config['url_epInfo%s' % ('', '_zip')[self.config['useZip']]] % (sid, language)
self.config['url_seriesInfo'] % (sid, getShowInLanguage) show_data = self._getetsrc(url, language=getShowInLanguage)
)
# check and make sure we have data to process and that it contains a series name # check and make sure we have data to process and that it contains a series name
if not len(seriesInfoEt) or (isinstance(seriesInfoEt, dict) and 'seriesname' not in seriesInfoEt['series']): if not len(show_data) or (isinstance(show_data, dict) and 'seriesname' not in show_data['series']):
return False return False
for k, v in seriesInfoEt['series'].items(): for k, v in show_data['series'].items():
if v is not None: if v is not None:
if k in ['banner', 'fanart', 'poster']: if k in ['banner', 'fanart', 'poster']:
v = self.config['url_artworkPrefix'] % (v) v = self.config['url_artworkPrefix'] % (v)
@ -865,16 +864,10 @@ class Tvdb:
# Parse episode data # Parse episode data
log().debug('Getting all episodes of %s' % (sid)) log().debug('Getting all episodes of %s' % (sid))
if self.config['useZip']: if 'episode' not in show_data:
url = self.config['url_epInfo_zip'] % (sid, language)
else:
url = self.config['url_epInfo'] % (sid, language)
epsEt = self._getetsrc(url, language=language)
if 'episode' not in epsEt:
return False return False
episodes = epsEt['episode'] episodes = show_data['episode']
if not isinstance(episodes, list): if not isinstance(episodes, list):
episodes = [episodes] episodes = [episodes]

View file

@ -404,7 +404,7 @@ class TVRage:
"https": self.config['proxy'], "https": self.config['proxy'],
} }
resp = session.get(url.strip(), cache_auto=True, params=params) resp = session.get(url.strip(), params=params)
else: else:
resp = requests.get(url.strip(), params=params) resp = requests.get(url.strip(), params=params)

View file

@ -1154,6 +1154,8 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
""" """
# request session # request session
if None is session:
session = requests.session()
cache_dir = sickbeard.CACHE_DIR or _getTempDir() cache_dir = sickbeard.CACHE_DIR or _getTempDir()
session = CacheControl(sess=session, cache=caches.FileCache(os.path.join(cache_dir, 'sessions'))) session = CacheControl(sess=session, cache=caches.FileCache(os.path.join(cache_dir, 'sessions')))
@ -1224,6 +1226,8 @@ def getURL(url, post_data=None, params=None, headers=None, timeout=30, session=N
def download_file(url, filename, session=None): def download_file(url, filename, session=None):
# create session # create session
if None is session:
session = requests.session()
cache_dir = sickbeard.CACHE_DIR or _getTempDir() cache_dir = sickbeard.CACHE_DIR or _getTempDir()
session = CacheControl(sess=session, cache=caches.FileCache(os.path.join(cache_dir, 'sessions'))) session = CacheControl(sess=session, cache=caches.FileCache(os.path.join(cache_dir, 'sessions')))

View file

@ -485,6 +485,10 @@ class TVShow(object):
cachedShow = t[self.indexerid] cachedShow = t[self.indexerid]
cachedSeasons = {} cachedSeasons = {}
if None is cachedShow:
logger.log(u'No cache showdata to parse from %s' % sickbeard.indexerApi(self.indexer).name)
return scannedEps
for curResult in sqlResults: for curResult in sqlResults:
deleteEp = False deleteEp = False