New searches now search only the indexer specified when importing existing shows.

Fixed bug causing addshow's to display the id of the show instead of the name.
This commit is contained in:
echel0n 2014-03-15 23:28:11 -07:00
parent b225794473
commit d0ac2936b0
6 changed files with 33 additions and 54 deletions

View file

@ -39,7 +39,9 @@
<input type="hidden" name="indexerLang" value="en" />
<input type="hidden" name="whichSeries" value="$provided_indexer_id" />
<input type="hidden" id="providedName" value="$provided_indexer_name" />
<input type="hidden" id="providedIndexer" value="$provided_indexer" />
#else:
<input type="hidden" id="providedIndexer" value="$provided_indexer" />
<input type="text" id="nameToSearch" value="$default_show_name" style="margin-top: 1px;" />
<select name="indexerLang" id="indexerLangSelect" style="height: 26px;margin-top: 1px;">
<option value="en" selected="selected">en</option>

View file

@ -36,7 +36,7 @@ $(document).ready(function () {
$('#searchResults').html('<img id="searchingAnim" src="' + sbRoot + '/images/loading32.gif" height="32" width="32" /> searching...');
$.getJSON(sbRoot + '/home/addShows/searchIndexersForShowName', {'name': $('#nameToSearch').val(), 'lang': $('#indexerLangSelect').val()}, function (data) {
$.getJSON(sbRoot + '/home/addShows/searchIndexersForShowName', {'name': $('#nameToSearch').val(), 'lang': $('#indexerLangSelect').val(), 'indexer': $('#providedIndexer').val()}, function (data) {
var firstResult = true;
var resultStr = '<fieldset>\n<legend>Search Results:</legend>\n';
var checked = '';
@ -146,7 +146,7 @@ $(document).ready(function () {
var show_name, sep_char;
// if they've picked a radio button then use that
if ($('input:radio[name=whichSeries]:checked').length) {
show_name = $('input:radio[name=whichSeries]:checked').val().split('|')[1];
show_name = $('input:radio[name=whichSeries]:checked').val().split('|')[2];
}
// if we provided a show in the hidden field, use that
else if ($('input:hidden[name=whichSeries]').length && $('input:hidden[name=whichSeries]').val().length) {

View file

@ -47,7 +47,6 @@ from tvdb_ui import BaseUI, ConsoleUI
from tvdb_exceptions import (tvdb_error, tvdb_userabort, tvdb_shownotfound,
tvdb_seasonnotfound, tvdb_episodenotfound, tvdb_attributenotfound)
lastTimeout = None
def log():
return logging.getLogger("tvdb_api")
@ -535,20 +534,23 @@ class Tvdb:
raise tvdb_error("Connection timed out " + str(e.message) + " while loading URL " + str(url))
except Exception, e:
raise tvdb_error("Unknown exception while loading URL " + str(url) + ": " + str(e))
raise tvdb_error("Unknown exception occured: " + str(e.message) + " while loading URL " + str(url))
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 resp.ok:
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
return resp.content
return None
def _getetsrc(self, url, params=None, language=None):
"""Loads a URL using caching, returns an ElementTree of the source

View file

@ -39,8 +39,6 @@ from tvrage_ui import BaseUI
from tvrage_exceptions import (tvrage_error, tvrage_userabort, tvrage_shownotfound,
tvrage_seasonnotfound, tvrage_episodenotfound, tvrage_attributenotfound)
lastTimeout = None
def log():
return logging.getLogger("tvrage_api")
@ -255,13 +253,7 @@ class TVRage:
trying again, and any requests within that one minute window will
return an exception immediately.
"""
global lastTimeout
# if we're given a lastTimeout that is less than 1 min just give up
if not forceConnect and lastTimeout != None and dt.datetime.now() - lastTimeout < dt.timedelta(minutes=1):
raise tvrage_error("We recently timed out, so giving up early this time")
self.shows = ShowContainer() # Holds all Show classes
self.corrections = {} # Holds show-name to show_id mapping
@ -354,7 +346,6 @@ class TVRage:
return os.path.join(tempfile.gettempdir(), "tvrage_api-%s" % (uid))
def _loadUrl(self, url, params=None):
global lastTimeout
try:
log().debug("Retrieving URL %s" % url)
@ -370,29 +361,12 @@ class TVRage:
raise tvrage_error("HTTP error " + str(e.errno) + " while loading URL " + str(url))
except requests.ConnectionError, e:
lastTimeout = dt.datetime.now()
raise tvrage_error("Connection error " + str(e.message) + " while loading URL " + str(url))
except requests.Timeout, e:
lastTimeout = dt.datetime.now()
raise tvrage_error("Connection timed out " + str(e.message) + " while loading URL " + str(url))
except Exception, e:
lastTimeout = dt.datetime.now()
raise tvrage_error("Unknown exception while loading URL " + str(url) + ": " + str(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
return resp.content if resp.ok else None
def _getetsrc(self, url, params=None):
"""Loads a URL using caching, returns an ElementTree of the source

View file

@ -196,11 +196,7 @@ Returns a byte-string retrieved from the url provider.
logger.log(u"Connection timed out " + str(e.message) + " while loading URL " + url, logger.WARNING)
return None
except Exception:
logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING)
return None
return resp.content
return resp.content if resp.ok else None
def _remove_file_failed(file):
try:

View file

@ -1900,7 +1900,7 @@ class NewHomeAddShows:
return helpers.sanitizeFileName(name)
@cherrypy.expose
def searchIndexersForShowName(self, name, lang="en"):
def searchIndexersForShowName(self, name, lang="en", indexer=None):
if not lang or lang == 'null':
lang = "en"
@ -1924,8 +1924,13 @@ class NewHomeAddShows:
paramsTVRAGE = {'show': searchTerm}
urlDataTVDB = helpers.getURL(baseURL_TVDB, params=paramsTVDB)
urlDataTVRAGE = helpers.getURL(baseURL_TVRAGE, params=paramsTVRAGE)
urlDataTVDB = None
if indexer is None or indexer in 'Tvdb':
urlDataTVDB = helpers.getURL(baseURL_TVDB, params=paramsTVDB)
urlDataTVRAGE = None
if indexer is None or indexer in 'TVRage':
urlDataTVRAGE = helpers.getURL(baseURL_TVRAGE, params=paramsTVRAGE)
if urlDataTVDB is None and urlDataTVRAGE is None:
# When urlData is None, trouble connecting to TVDB and TVRage, don't try the rest of the keywords
@ -2078,10 +2083,10 @@ class NewHomeAddShows:
else:
use_provided_info = False
# tell the template whether we're giving it show name & TVDB ID
# tell the template whether we're giving it show name & Indexer ID
t.use_provided_info = use_provided_info
# use the given show_dir for the tvdb search if available
# use the given show_dir for the indexer search if available
if not show_dir:
t.default_show_name = ''
elif not show_name:
@ -2097,11 +2102,11 @@ class NewHomeAddShows:
if use_provided_info:
t.provided_indexer_id = indexer_id
t.provided_indexer = indexer
t.provided_indexer_name = show_name
t.provided_show_dir = show_dir
t.other_shows = other_shows
t.provided_indexer = indexer
return _munge(t)