mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
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:
parent
b225794473
commit
d0ac2936b0
6 changed files with 33 additions and 54 deletions
|
@ -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>
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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,20 +534,23 @@ 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 'application/zip' in resp.headers.get("Content-Type", ''):
|
if resp.ok:
|
||||||
try:
|
if 'application/zip' in resp.headers.get("Content-Type", ''):
|
||||||
# TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20]
|
try:
|
||||||
log().debug("We recived a zip file unpacking now ...")
|
# TODO: The zip contains actors.xml and banners.xml, which are currently ignored [GH-20]
|
||||||
zipdata = StringIO.StringIO()
|
log().debug("We recived a zip file unpacking now ...")
|
||||||
zipdata.write(resp.content)
|
zipdata = StringIO.StringIO()
|
||||||
myzipfile = zipfile.ZipFile(zipdata)
|
zipdata.write(resp.content)
|
||||||
return myzipfile.read('%s.xml' % language)
|
myzipfile = zipfile.ZipFile(zipdata)
|
||||||
except zipfile.BadZipfile:
|
return myzipfile.read('%s.xml' % language)
|
||||||
raise tvdb_error("Bad zip file received from thetvdb.com, could not read it")
|
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):
|
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
|
||||||
|
|
|
@ -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")
|
||||||
|
|
||||||
|
@ -255,13 +253,7 @@ class TVRage:
|
||||||
trying again, and any requests within that one minute window will
|
trying again, and any requests within that one minute window will
|
||||||
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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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,8 +1924,13 @@ class NewHomeAddShows:
|
||||||
|
|
||||||
paramsTVRAGE = {'show': searchTerm}
|
paramsTVRAGE = {'show': searchTerm}
|
||||||
|
|
||||||
urlDataTVDB = helpers.getURL(baseURL_TVDB, params=paramsTVDB)
|
urlDataTVDB = None
|
||||||
urlDataTVRAGE = helpers.getURL(baseURL_TVRAGE, params=paramsTVRAGE)
|
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:
|
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
|
# 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:
|
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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue