From cb514dfedeb8c507b5cd63bb161004debb47ef2f Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Tue, 19 Nov 2013 16:26:40 -0800 Subject: [PATCH] tvdb: don't download zip files, just use the xml endpoint --- plugins/tvdb.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/plugins/tvdb.py b/plugins/tvdb.py index 14aeb5a..81f023a 100644 --- a/plugins/tvdb.py +++ b/plugins/tvdb.py @@ -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