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="indexerLang" value="en" />
<input type="hidden" name="whichSeries" value="$provided_indexer_id" /> <input type="hidden" name="whichSeries" value="$provided_indexer_id" />
<input type="hidden" id="providedName" value="$provided_indexer_name" /> <input type="hidden" id="providedName" value="$provided_indexer_name" />
<input type="hidden" id="providedIndexer" value="$provided_indexer" />
#else: #else:
<input type="hidden" id="providedIndexer" value="$provided_indexer" />
<input type="text" id="nameToSearch" value="$default_show_name" style="margin-top: 1px;" /> <input type="text" id="nameToSearch" value="$default_show_name" style="margin-top: 1px;" />
<select name="indexerLang" id="indexerLangSelect" style="height: 26px;margin-top: 1px;"> <select name="indexerLang" id="indexerLangSelect" style="height: 26px;margin-top: 1px;">
<option value="en" selected="selected">en</option> <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...'); $('#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 firstResult = true;
var resultStr = '<fieldset>\n<legend>Search Results:</legend>\n'; var resultStr = '<fieldset>\n<legend>Search Results:</legend>\n';
var checked = ''; var checked = '';
@ -146,7 +146,7 @@ $(document).ready(function () {
var show_name, sep_char; var show_name, sep_char;
// if they've picked a radio button then use that // if they've picked a radio button then use that
if ($('input:radio[name=whichSeries]:checked').length) { 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 // if we provided a show in the hidden field, use that
else if ($('input:hidden[name=whichSeries]').length && $('input:hidden[name=whichSeries]').val().length) { 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, from tvdb_exceptions import (tvdb_error, tvdb_userabort, tvdb_shownotfound,
tvdb_seasonnotfound, tvdb_episodenotfound, tvdb_attributenotfound) tvdb_seasonnotfound, tvdb_episodenotfound, tvdb_attributenotfound)
lastTimeout = None
def log(): def log():
return logging.getLogger("tvdb_api") return logging.getLogger("tvdb_api")
@ -535,8 +534,9 @@ class Tvdb:
raise tvdb_error("Connection timed out " + str(e.message) + " while loading URL " + str(url)) raise tvdb_error("Connection timed out " + str(e.message) + " while loading URL " + str(url))
except Exception, e: 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 resp.ok:
if 'application/zip' in resp.headers.get("Content-Type", ''): if 'application/zip' in resp.headers.get("Content-Type", ''):
try: try:
# TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20] # TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20]
@ -550,6 +550,8 @@ class Tvdb:
return resp.content return resp.content
return None
def _getetsrc(self, url, params=None, language=None): def _getetsrc(self, url, params=None, language=None):
"""Loads a URL using caching, returns an ElementTree of the source """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, from tvrage_exceptions import (tvrage_error, tvrage_userabort, tvrage_shownotfound,
tvrage_seasonnotfound, tvrage_episodenotfound, tvrage_attributenotfound) tvrage_seasonnotfound, tvrage_episodenotfound, tvrage_attributenotfound)
lastTimeout = None
def log(): def log():
return logging.getLogger("tvrage_api") return logging.getLogger("tvrage_api")
@ -256,12 +254,6 @@ class TVRage:
return an exception immediately. 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.shows = ShowContainer() # Holds all Show classes
self.corrections = {} # Holds show-name to show_id mapping 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)) return os.path.join(tempfile.gettempdir(), "tvrage_api-%s" % (uid))
def _loadUrl(self, url, params=None): def _loadUrl(self, url, params=None):
global lastTimeout
try: try:
log().debug("Retrieving URL %s" % url) 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)) raise tvrage_error("HTTP error " + str(e.errno) + " while loading URL " + str(url))
except requests.ConnectionError, e: except requests.ConnectionError, e:
lastTimeout = dt.datetime.now()
raise tvrage_error("Connection error " + str(e.message) + " while loading URL " + str(url)) raise tvrage_error("Connection error " + str(e.message) + " while loading URL " + str(url))
except requests.Timeout, e: except requests.Timeout, e:
lastTimeout = dt.datetime.now()
raise tvrage_error("Connection timed out " + str(e.message) + " while loading URL " + str(url)) raise tvrage_error("Connection timed out " + str(e.message) + " while loading URL " + str(url))
except Exception, e: return resp.content if resp.ok else None
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
def _getetsrc(self, url, params=None): def _getetsrc(self, url, params=None):
"""Loads a URL using caching, returns an ElementTree of the source """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) logger.log(u"Connection timed out " + str(e.message) + " while loading URL " + url, logger.WARNING)
return None return None
except Exception: return resp.content if resp.ok else None
logger.log(u"Unknown exception while loading URL " + url + ": " + traceback.format_exc(), logger.WARNING)
return None
return resp.content
def _remove_file_failed(file): def _remove_file_failed(file):
try: try:

View file

@ -1900,7 +1900,7 @@ class NewHomeAddShows:
return helpers.sanitizeFileName(name) return helpers.sanitizeFileName(name)
@cherrypy.expose @cherrypy.expose
def searchIndexersForShowName(self, name, lang="en"): def searchIndexersForShowName(self, name, lang="en", indexer=None):
if not lang or lang == 'null': if not lang or lang == 'null':
lang = "en" lang = "en"
@ -1924,7 +1924,12 @@ class NewHomeAddShows:
paramsTVRAGE = {'show': searchTerm} paramsTVRAGE = {'show': searchTerm}
urlDataTVDB = None
if indexer is None or indexer in 'Tvdb':
urlDataTVDB = helpers.getURL(baseURL_TVDB, params=paramsTVDB) urlDataTVDB = helpers.getURL(baseURL_TVDB, params=paramsTVDB)
urlDataTVRAGE = None
if indexer is None or indexer in 'TVRage':
urlDataTVRAGE = helpers.getURL(baseURL_TVRAGE, params=paramsTVRAGE) urlDataTVRAGE = helpers.getURL(baseURL_TVRAGE, params=paramsTVRAGE)
if urlDataTVDB is None and urlDataTVRAGE is None: if urlDataTVDB is None and urlDataTVRAGE is None:
@ -2078,10 +2083,10 @@ class NewHomeAddShows:
else: else:
use_provided_info = False 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 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: if not show_dir:
t.default_show_name = '' t.default_show_name = ''
elif not show_name: elif not show_name:
@ -2097,11 +2102,11 @@ class NewHomeAddShows:
if use_provided_info: if use_provided_info:
t.provided_indexer_id = indexer_id t.provided_indexer_id = indexer_id
t.provided_indexer = indexer
t.provided_indexer_name = show_name t.provided_indexer_name = show_name
t.provided_show_dir = show_dir t.provided_show_dir = show_dir
t.other_shows = other_shows t.other_shows = other_shows
t.provided_indexer = indexer
return _munge(t) return _munge(t)