tvdb: don't download zip files, just use the xml endpoint
This commit is contained in:
parent
980ebad385
commit
cb514dfede
|
@ -1,12 +1,9 @@
|
|||
"""
|
||||
TV information, written by Lurchington 2010
|
||||
modified by rmmh 2010
|
||||
modified by rmmh 2010, 2013
|
||||
"""
|
||||
|
||||
import datetime
|
||||
from urllib2 import URLError
|
||||
from zipfile import ZipFile
|
||||
from cStringIO import StringIO
|
||||
|
||||
from lxml import etree
|
||||
from util import hook, http, timesince
|
||||
|
@ -16,21 +13,12 @@ base_url = "http://thetvdb.com/api/"
|
|||
api_key = "469B73127CA0C411"
|
||||
|
||||
|
||||
def get_zipped_xml(*args, **kwargs):
|
||||
try:
|
||||
path = kwargs.pop("path")
|
||||
except KeyError:
|
||||
raise KeyError("must specify a path for the zipped file to be read")
|
||||
zip_buffer = StringIO(http.get(*args, **kwargs))
|
||||
return etree.parse(ZipFile(zip_buffer, "r").open(path))
|
||||
|
||||
|
||||
def get_episodes_for_series(seriesname):
|
||||
res = {"error": None, "ended": False, "episodes": None, "name": None}
|
||||
# http://thetvdb.com/wiki/index.php/API:GetSeries
|
||||
try:
|
||||
query = http.get_xml(base_url + 'GetSeries.php', seriesname=seriesname)
|
||||
except URLError:
|
||||
except http.URLError:
|
||||
res["error"] = "error contacting thetvdb.com"
|
||||
return res
|
||||
|
||||
|
@ -43,9 +31,8 @@ def get_episodes_for_series(seriesname):
|
|||
series_id = series_id[0]
|
||||
|
||||
try:
|
||||
series = get_zipped_xml(base_url + '%s/series/%s/all/en.zip' %
|
||||
(api_key, series_id), path="en.xml")
|
||||
except URLError:
|
||||
series = http.get_xml(base_url + '%s/series/%s/all/en.xml' % (api_key, series_id))
|
||||
except http.URLError:
|
||||
res["error"] = "error contacting thetvdb.com"
|
||||
return res
|
||||
|
||||
|
|
Loading…
Reference in New Issue