mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
couple of bugfixes for TVDB Api code and another in the show metadata parser
This commit is contained in:
parent
40c69d6a0f
commit
4dce609667
3 changed files with 28 additions and 25 deletions
|
@ -39,7 +39,6 @@ except ImportError:
|
|||
gzip = None
|
||||
|
||||
from lib import requests
|
||||
from urlparse import urlparse, urlsplit
|
||||
from lib.cachecontrol.wrapper import CacheControl
|
||||
from lib.cachecontrol.caches.file_cache import FileCache
|
||||
|
||||
|
@ -538,26 +537,16 @@ class Tvdb:
|
|||
lastTimeout = datetime.datetime.now()
|
||||
raise tvdb_error("Could not connect to server: %s" % (e))
|
||||
|
||||
## handle gzipped content,
|
||||
## http://dbr.lighthouseapp.com/projects/13342/tickets/72-gzipped-data-patch
|
||||
#if 'gzip' in resp.headers.get("Content-Encoding", ''):
|
||||
# if gzip:
|
||||
# stream = StringIO.StringIO(resp.content)
|
||||
# gz = gzip.GzipFile(fileobj=stream)
|
||||
# return gz.read()
|
||||
#
|
||||
# raise tvdb_error("Received gzip data from thetvdb.com, but could not correctly handle it")
|
||||
#
|
||||
#if 'application/zip' in resp.headers.get("Content-Type", ''):
|
||||
# try:
|
||||
# # TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20]
|
||||
# log().debug("We recived a zip file unpacking now ...")
|
||||
# zipdata = StringIO.StringIO()
|
||||
# zipdata.write(resp.content)
|
||||
# myzipfile = zipfile.ZipFile(zipdata)
|
||||
# return myzipfile.read('%s.xml' % language)
|
||||
# except zipfile.BadZipfile:
|
||||
# raise tvdb_error("Bad zip file received from thetvdb.com, could not read it")
|
||||
if 'application/zip' in resp.headers.get("Content-Type", ''):
|
||||
try:
|
||||
# TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20]
|
||||
log().debug("We recived a zip file unpacking now ...")
|
||||
zipdata = StringIO.StringIO()
|
||||
zipdata.write(resp.content)
|
||||
myzipfile = zipfile.ZipFile(zipdata)
|
||||
return myzipfile.read('%s.xml' % language)
|
||||
except zipfile.BadZipfile:
|
||||
raise tvdb_error("Bad zip file received from thetvdb.com, could not read it")
|
||||
|
||||
return resp.content
|
||||
|
||||
|
@ -570,7 +559,7 @@ class Tvdb:
|
|||
# remove it to avoid errors. Change from SickBeard, from will14m
|
||||
return ElementTree.fromstring(src.rstrip("\r"))
|
||||
except SyntaxError:
|
||||
src = self._loadUrl(url, params=None, language=language)
|
||||
src = self._loadUrl(url, params=params, language=language)
|
||||
try:
|
||||
return ElementTree.fromstring(src.rstrip("\r"))
|
||||
except SyntaxError, exceptionmsg:
|
||||
|
|
|
@ -20,6 +20,8 @@ import getpass
|
|||
import tempfile
|
||||
import warnings
|
||||
import logging
|
||||
import StringIO
|
||||
import zipfile
|
||||
import datetime as dt
|
||||
|
||||
try:
|
||||
|
@ -369,6 +371,17 @@ class TVRage:
|
|||
lastTimeout = dt.datetime.now()
|
||||
raise tvrage_error("Could not connect to server: %s" % (e))
|
||||
|
||||
if 'application/zip' in resp.headers.get("Content-Type", ''):
|
||||
try:
|
||||
# TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20]
|
||||
log().debug("We recived a zip file unpacking now ...")
|
||||
zipdata = StringIO.StringIO()
|
||||
zipdata.write(resp.content)
|
||||
myzipfile = zipfile.ZipFile(zipdata)
|
||||
return myzipfile.read('%s.xml' % self.config['language'])
|
||||
except zipfile.BadZipfile:
|
||||
raise tvrage_error("Bad zip file received from tvrage.com, could not read it")
|
||||
|
||||
return resp.content
|
||||
|
||||
def _getetsrc(self, url, params=None):
|
||||
|
|
|
@ -31,6 +31,7 @@ from sickbeard.metadata import helpers as metadata_helpers
|
|||
from sickbeard import logger
|
||||
from sickbeard import encodingKludge as ek
|
||||
from sickbeard.exceptions import ex
|
||||
from sickbeard.show_name_helpers import allPossibleShowNames
|
||||
|
||||
from lib.tmdb_api.tmdb_api import TMDB
|
||||
from sickbeard.indexers import indexer_api, indexer_exceptions
|
||||
|
@ -751,11 +752,11 @@ class GenericMetadata():
|
|||
|
||||
# Try and get posters and fanart from TMDB
|
||||
if image_url is None:
|
||||
for showname in show_obj.name, show_obj.exceptions:
|
||||
for show_name in set(allPossibleShowNames(show_obj)):
|
||||
if image_type in ('poster', 'poster_thumb'):
|
||||
image_url = self._retrieve_show_images_from_tmdb(showname, poster=True)
|
||||
image_url = self._retrieve_show_images_from_tmdb(show_name, poster=True)
|
||||
elif image_type == 'fanart':
|
||||
image_url = self._retrieve_show_images_from_tmdb(showname, backdrop=True)
|
||||
image_url = self._retrieve_show_images_from_tmdb(show_name, backdrop=True)
|
||||
|
||||
if image_url:
|
||||
break
|
||||
|
|
Loading…
Reference in a new issue