1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Re-wrote the indexerApi wrapper, was causing a bottlekneck

Fixed bug when show folder is deleted before being deleted from SB
New Show searches now confirm results have a valid firstaired date
This commit is contained in:
echel0n 2014-03-26 12:28:46 -07:00
parent 3534574741
commit 8004685d3f
19 changed files with 117 additions and 194 deletions

View File

@ -30,7 +30,7 @@
#end if #end if
<td> <td>
<select name="indexer"> <select name="indexer">
#for $curIndexer in $sickbeard.indexerApi().indexers.items(): #for $curIndexer in $sickbeard.indexerApi.indexers().items():
<option value="$curIndexer[0]" #if $curIndexer[0] == $indexer then "selected=\"selected\"" else ""#>$curIndexer[1]</option> <option value="$curIndexer[0]" #if $curIndexer[0] == $indexer then "selected=\"selected\"" else ""#>$curIndexer[1]</option>
#end for #end for
</select> </select>

View File

@ -304,9 +304,9 @@ def searchIndexerForShowID(regShowName, indexer, indexer_id=None):
showNames = [re.sub('[. -]', ' ', regShowName), regShowName] showNames = [re.sub('[. -]', ' ', regShowName), regShowName]
# Query Indexers for each search term and build the list of results # Query Indexers for each search term and build the list of results
lINDEXER_API_PARMS = {'indexer': indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
for name in showNames: for name in showNames:
logger.log(u"Trying to find " + name + " on " + sickbeard.indexerApi(indexer).name, logger.DEBUG) logger.log(u"Trying to find " + name + " on " + sickbeard.indexerApi(indexer).name, logger.DEBUG)
@ -326,7 +326,7 @@ def searchIndexerForShowID(regShowName, indexer, indexer_id=None):
name = name.encode('UTF-8').lower() name = name.encode('UTF-8').lower()
if (seriesname == name) or (indexer_id is not None and part['id'] == indexer_id): if (seriesname == name) or (indexer_id is not None and part['id'] == indexer_id):
return [t.config['id'], part['id']] return [sickbeard.indexerApi(indexer).config['id'], part['id']]
except KeyError, e: except KeyError, e:
break break
@ -942,38 +942,23 @@ def get_show_by_name(name, showList, useIndexer=False):
return show return show
if useIndexer: if useIndexer:
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi.indexers():
try: try:
lINDEXER_API_PARMS = {'indexer': indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
lINDEXER_API_PARMS['search_all_languages'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
showObj = t[name] showObj = t[name]
except (sickbeard.indexer_exception, IOError): except:continue
# if none found, search on all languages
try:
lINDEXER_API_PARMS = {'indexer': indexer}
lINDEXER_API_PARMS['search_all_languages'] = True if showObj:
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI showResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
if showResult is not None:
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) return showResult
showObj = t[name]
except (sickbeard.indexer_exception, IOError):
pass
continue
except (IOError):
continue
showResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
if showResult is not None:
return showResult
return None return None
def suffix(d): def suffix(d):
return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th') return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')

View File

@ -20,28 +20,37 @@ import sickbeard
from indexer_config import initConfig, indexerConfig from indexer_config import initConfig, indexerConfig
class indexerApi(object): class indexerApi(object):
def __init__(self, indexer=None, *args, **kwargs): def __init__(self, indexerID=None):
self._wrapped = object self.indexerID = indexerID
self.config = initConfig
self.indexers = {k: v if k is 'id' else v['name'] for k, v in indexerConfig.items()}
if indexer in indexerConfig: def indexer(self, *args, **kwargs):
self.name = indexerConfig[indexer]['name'] if self.indexerID:
self.config = indexerConfig[indexer] return indexerConfig[self.indexerID]['module'](*args, **kwargs)
# set cache if exists @property
if sickbeard.CACHE_DIR: indexerConfig[indexer]['api_params']['cache'] = os.path.join(sickbeard.CACHE_DIR, def config(self):
self.name) if self.indexerID:
# update API params return indexerConfig[self.indexerID]
indexerConfig[indexer]['api_params'].update(**kwargs) return initConfig
# wrap the indexer API object and return it back @property
self._wrapped = indexerConfig[indexer]['module'](*args, **indexerConfig[indexer]['api_params']) def name(self):
if self.indexerID:
return indexerConfig[self.indexerID]['name']
def __getattr__(self, attr): @property
return getattr(self._wrapped, attr) def api_params(self):
if self.indexerID:
if sickbeard.CACHE_DIR:
indexerConfig[self.indexerID]['api_params']['cache'] = os.path.join(sickbeard.CACHE_DIR, self.name)
return indexerConfig[self.indexerID]['api_params']
def __getitem__(self, attr): @property
return self._wrapped.__getitem__(attr) def cache(self):
if sickbeard.CACHE_DIR:
return self.api_params['cache']
@staticmethod
def indexers():
return {k: v if k is 'id' else v['name'] for k, v in indexerConfig.items()}

View File

@ -11,91 +11,26 @@ sys.path.append(os.path.abspath('..'))
sys.path.append(os.path.abspath('../../../lib')) sys.path.append(os.path.abspath('../../../lib'))
import sickbeard import sickbeard
import itertools
from itertools import chain
from sickbeard import classes
class APICheck(unittest.TestCase): class APICheck(unittest.TestCase):
indexer = u'3' indexer_id = 2930
for i in int([indexer]) and sickbeard.indexerApi().indexers:
print i
global indexer, keywords, nameUTF8
indexer = 0
name = 'american dad'
lang = "en" lang = "en"
if not lang or lang == 'null': for indexer in sickbeard.indexerApi.indexers():
lang = "en" print indexer
print sickbeard.indexerApi().config['langabbv_to_id'][lang]
print sickbeard.indexerApi(indexer).cache
print sickbeard.indexerApi(indexer).name
print sickbeard.indexerApi(indexer).config['scene_url']
print sickbeard.indexerApi().config['valid_languages']
results = [] lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['cache'] = True
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[indexer_id].airedOn(1)[0]
nameUTF8 = name.encode('utf-8') season = int(epObj["seasonnumber"])
episodes = [int(epObj["episodenumber"])]
# Use each word in the show's name as a possible search term
keywords = nameUTF8.split(' ')
# Insert the whole show's name as the first search term so best results are first
# ex: keywords = ['Some Show Name', 'Some', 'Show', 'Name']
if len(keywords) > 1:
keywords.insert(0, nameUTF8)
# check for indexer preset
indexers = [int(indexer)]
if 0 in indexers:
indexers = sickbeard.indexerApi().indexers
# Query Indexers for each search term and build the list of results
for i in indexers:
def searchShows(i):
results = []
lINDEXER_API_PARMS = {'indexer': i}
lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
for searchTerm in keywords:
try:
search = t[searchTerm]
if isinstance(search, dict):
search = [search]
# add search results
result = [
[t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'], x['firstaired']]
for x in search if nameUTF8.lower() in x['seriesname'].lower()]
# see if we have any matches
if len(result) > 0:
# add result to list of found shows
results += result
# search through result to see if we have a exact match
for show in result:
# cleanup the series name
seriesname = show[4].encode('utf-8').translate(None, string.punctuation)
# check if we got a exact match
if nameUTF8.lower() == seriesname.lower():
return results
except Exception, e:
continue
# finished searching a indexer so return the results
return results
# search indexers for shows
results += searchShows(i)
# remove duplicates
results = list(results for results, _ in itertools.groupby(results))
print results
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -349,7 +349,7 @@ class GenericMetadata():
try: try:
# There's gotta be a better way of doing this but we don't wanna # There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere # change the language value elsewhere
lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -359,7 +359,7 @@ class GenericMetadata():
if ep_obj.show.dvdorder != 0: if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[ep_obj.show.indexerid] indexer_show_obj = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e: except sickbeard.indexer_shownotfound, e:
@ -739,7 +739,7 @@ class GenericMetadata():
try: try:
# There's gotta be a better way of doing this but we don't wanna # There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere # change the language value elsewhere
lINDEXER_API_PARMS = {'indexer': show_obj.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['banners'] = True lINDEXER_API_PARMS['banners'] = True
@ -749,7 +749,7 @@ class GenericMetadata():
if show_obj.dvdorder != 0: if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[show_obj.indexerid] indexer_show_obj = t[show_obj.indexerid]
except (sickbeard.indexer_error, IOError), e: except (sickbeard.indexer_error, IOError), e:
logger.log(u"Unable to look up show on " + sickbeard.indexerApi( logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
@ -804,7 +804,7 @@ class GenericMetadata():
try: try:
# There's gotta be a better way of doing this but we don't wanna # There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere # change the language value elsewhere
lINDEXER_API_PARMS = {'indexer': show_obj.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['banners'] = True lINDEXER_API_PARMS['banners'] = True
@ -814,7 +814,7 @@ class GenericMetadata():
if show_obj.dvdorder != 0: if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[show_obj.indexerid] indexer_show_obj = t[show_obj.indexerid]
except (sickbeard.indexer_error, IOError), e: except (sickbeard.indexer_error, IOError), e:
logger.log(u"Unable to look up show on " + sickbeard.indexerApi( logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
@ -860,14 +860,14 @@ class GenericMetadata():
try: try:
# There's gotta be a better way of doing this but we don't wanna # There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere # change the language value elsewhere
lINDEXER_API_PARMS = {'indexer': show_obj.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['banners'] = True lINDEXER_API_PARMS['banners'] = True
if indexer_lang and not indexer_lang == 'en': if indexer_lang and not indexer_lang == 'en':
lINDEXER_API_PARMS['language'] = indexer_lang lINDEXER_API_PARMS['language'] = indexer_lang
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
indexer_show_obj = t[show_obj.indexerid] indexer_show_obj = t[show_obj.indexerid]
except (sickbeard.indexer_error, IOError), e: except (sickbeard.indexer_error, IOError), e:
logger.log(u"Unable to look up show on " + sickbeard.indexerApi( logger.log(u"Unable to look up show on " + sickbeard.indexerApi(

View File

@ -228,7 +228,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
indexer_lang = show_obj.lang indexer_lang = show_obj.lang
# There's gotta be a better way of doing this but we don't wanna # There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere # change the language value elsewhere
lINDEXER_API_PARMS = {'indexer': show_obj.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -238,7 +238,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
if show_obj.dvdorder != 0: if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
tv_node = etree.Element("Series") tv_node = etree.Element("Series")
@ -395,7 +395,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang indexer_lang = ep_obj.show.lang
try: try:
lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -405,7 +405,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
if ep_obj.show.dvdorder != 0: if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid] myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e: except sickbeard.indexer_shownotfound, e:

View File

@ -166,7 +166,7 @@ class TIVOMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang indexer_lang = ep_obj.show.lang
try: try:
lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -176,7 +176,7 @@ class TIVOMetadata(generic.GenericMetadata):
if ep_obj.show.dvdorder != 0: if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid] myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e: except sickbeard.indexer_shownotfound, e:
raise exceptions.ShowNotFoundException(str(e)) raise exceptions.ShowNotFoundException(str(e))

View File

@ -177,7 +177,7 @@ class WDTVMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang indexer_lang = ep_obj.show.lang
try: try:
lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -187,7 +187,7 @@ class WDTVMetadata(generic.GenericMetadata):
if ep_obj.show.dvdorder != 0: if ep_obj.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid] myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e: except sickbeard.indexer_shownotfound, e:
raise exceptions.ShowNotFoundException(e.message) raise exceptions.ShowNotFoundException(e.message)

View File

@ -97,7 +97,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
show_ID = show_obj.indexerid show_ID = show_obj.indexerid
indexer_lang = show_obj.lang indexer_lang = show_obj.lang
lINDEXER_API_PARMS = {'indexer': show_obj.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(show_obj.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -107,7 +107,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
if show_obj.dvdorder != 0: if show_obj.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(show_obj.indexer).indexer(**lINDEXER_API_PARMS)
tv_node = etree.Element("tvshow") tv_node = etree.Element("tvshow")
@ -221,7 +221,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
indexer_lang = ep_obj.show.lang indexer_lang = ep_obj.show.lang
lINDEXER_API_PARMS = {'indexer': ep_obj.show.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
lINDEXER_API_PARMS['actors'] = True lINDEXER_API_PARMS['actors'] = True
@ -232,7 +232,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
try: try:
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
myShow = t[ep_obj.show.indexerid] myShow = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound, e: except sickbeard.indexer_shownotfound, e:
raise exceptions.ShowNotFoundException(e.message) raise exceptions.ShowNotFoundException(e.message)

View File

@ -284,13 +284,13 @@ class NameParser(object):
# see if we can find the name with a TVDB lookup # see if we can find the name with a TVDB lookup
if check_indexer: if check_indexer:
for cur_name in name_list: for cur_name in name_list:
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi.indexers():
try: try:
lINDEXER_API_PARMS = {'indexer': indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
logger.log(u"Looking up name " + str(cur_name) + " on " + sickbeard.indexerApi(indexer).name, logger.log(u"Looking up name " + str(cur_name) + " on " + sickbeard.indexerApi(indexer).name,
logger.DEBUG) logger.DEBUG)
@ -298,12 +298,12 @@ class NameParser(object):
except (sickbeard.indexer_exception): except (sickbeard.indexer_exception):
# if none found, search on all languages # if none found, search on all languages
try: try:
lINDEXER_API_PARMS = {'indexer': indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
lINDEXER_API_PARMS['search_all_languages'] = True lINDEXER_API_PARMS['search_all_languages'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
logger.log( logger.log(
u"Looking up name " + str(cur_name) + " in all languages on " + sickbeard.indexerApi( u"Looking up name " + str(cur_name) + " in all languages on " + sickbeard.indexerApi(

View File

@ -599,12 +599,11 @@ class PostProcessor(object):
raise #TODO: later I'll just log this, for now I want to know about it ASAP raise #TODO: later I'll just log this, for now I want to know about it ASAP
try: try:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if indexer_lang and not indexer_lang == 'en': if indexer_lang and not indexer_lang == 'en':
lINDEXER_API_PARMS = {'language': indexer_lang} lINDEXER_API_PARMS = {'language': indexer_lang}
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[indexer_id].airedOn(episodes[0])[0] epObj = t[indexer_id].airedOn(episodes[0])[0]
@ -831,7 +830,7 @@ class PostProcessor(object):
# try to find the file info # try to find the file info
indexer_id = season = episodes = None indexer_id = season = episodes = None
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi.indexers():
self.indexer = int(indexer) self.indexer = int(indexer)
self._log(u"Searching " + sickbeard.indexerApi(self.indexer).name + ", trying to auto-detect Indexer for " self._log(u"Searching " + sickbeard.indexerApi(self.indexer).name + ", trying to auto-detect Indexer for "

View File

@ -169,14 +169,12 @@ class ProperFinder():
raise Exception("BAD STUFF HAPPENED") raise Exception("BAD STUFF HAPPENED")
indexer_lang = showObj.lang indexer_lang = showObj.lang
lINDEXER_API_PARMS = sickbeard.indexerApi(showObj.indexer).api_params.copy()
lINDEXER_API_PARMS = {'indexer': showObj.indexer}
if indexer_lang and not indexer_lang == 'en': if indexer_lang and not indexer_lang == 'en':
lINDEXER_API_PARMS['language'] = indexer_lang lINDEXER_API_PARMS['language'] = indexer_lang
try: try:
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(showObj.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[curProper.indexerid].airedOn(curProper.episode)[0] epObj = t[curProper.indexerid].airedOn(curProper.episode)[0]

View File

@ -73,7 +73,7 @@ def retrieve_exceptions():
# exceptions are stored on github pages # exceptions are stored on github pages
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi.indexers():
logger.log(u"Checking for scene exception updates for " + sickbeard.indexerApi(indexer).name + "") logger.log(u"Checking for scene exception updates for " + sickbeard.indexerApi(indexer).name + "")
url = sickbeard.indexerApi(indexer).config['scene_url'] url = sickbeard.indexerApi(indexer).config['scene_url']

View File

@ -53,8 +53,8 @@ class ShowUpdater():
# clean out cache directory, remove everything > 12 hours old # clean out cache directory, remove everything > 12 hours old
if sickbeard.CACHE_DIR: if sickbeard.CACHE_DIR:
for indexer in sickbeard.indexerApi().indexers: for indexer in sickbeard.indexerApi.indexers():
cache_dir = sickbeard.indexerApi(indexer).config['api_params']['cache'] cache_dir = sickbeard.indexerApi(indexer).cache
logger.log(u"Trying to clean cache folder " + cache_dir) logger.log(u"Trying to clean cache folder " + cache_dir)
# Does our cache_dir exists # Does our cache_dir exists

View File

@ -240,14 +240,13 @@ class QueueItemAdd(ShowQueueItem):
# make sure the indexer ids are valid # make sure the indexer ids are valid
try: try:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if self.lang: if self.lang:
lINDEXER_API_PARMS['language'] = self.lang lINDEXER_API_PARMS['language'] = self.lang
logger.log(u"" + sickbeard.indexerApi(self.indexer).name + ": " + repr(lINDEXER_API_PARMS)) logger.log(u"" + sickbeard.indexerApi(self.indexer).name + ": " + repr(lINDEXER_API_PARMS))
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
s = t[self.indexer_id] s = t[self.indexer_id]
# this usually only happens if they have an NFO in their show dir which gave us a indexer ID that has no proper english version of the show # this usually only happens if they have an NFO in their show dir which gave us a indexer ID that has no proper english version of the show

View File

@ -98,10 +98,8 @@ class TVShow(object):
if ek.ek(os.path.isdir, self._location): if ek.ek(os.path.isdir, self._location):
return self._location return self._location
elif self._isDirGood:
return self._location
else: else:
raise exceptions.NoNFOException("Show folder doesn't exist, you shouldn't be using it") raise exceptions.ShowDirNotFoundException("Show folder doesn't exist, you shouldn't be using it")
def _setLocation(self, newLocation): def _setLocation(self, newLocation):
logger.log(u"Setter sets location to " + newLocation, logger.DEBUG) logger.log(u"Setter sets location to " + newLocation, logger.DEBUG)
@ -358,7 +356,7 @@ class TVShow(object):
scannedEps = {} scannedEps = {}
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if self.lang: if self.lang:
lINDEXER_API_PARMS['language'] = self.lang lINDEXER_API_PARMS['language'] = self.lang
@ -366,7 +364,7 @@ class TVShow(object):
if self.dvdorder != 0: if self.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
cachedShow = t[self.indexerid] cachedShow = t[self.indexerid]
cachedSeasons = {} cachedSeasons = {}
@ -409,7 +407,7 @@ class TVShow(object):
def loadEpisodesFromIndexer(self, cache=True): def loadEpisodesFromIndexer(self, cache=True):
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not cache: if not cache:
lINDEXER_API_PARMS['cache'] = False lINDEXER_API_PARMS['cache'] = False
@ -421,7 +419,7 @@ class TVShow(object):
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
try: try:
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
showObj = t[self.indexerid] showObj = t[self.indexerid]
except sickbeard.indexer_error: except sickbeard.indexer_error:
logger.log(u"" + sickbeard.indexerApi( logger.log(u"" + sickbeard.indexerApi(
@ -522,7 +520,7 @@ class TVShow(object):
# if we have an air-by-date show then get the real season/episode numbers # if we have an air-by-date show then get the real season/episode numbers
if parse_result.air_by_date: if parse_result.air_by_date:
try: try:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if self.lang: if self.lang:
lINDEXER_API_PARMS['language'] = self.lang lINDEXER_API_PARMS['language'] = self.lang
@ -530,7 +528,7 @@ class TVShow(object):
if self.dvdorder != 0: if self.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[self.indexerid].airedOn(parse_result.air_date)[0] epObj = t[self.indexerid].airedOn(parse_result.air_date)[0]
season = int(epObj["seasonnumber"]) season = int(epObj["seasonnumber"])
@ -731,7 +729,7 @@ class TVShow(object):
# There's gotta be a better way of doing this but we don't wanna # There's gotta be a better way of doing this but we don't wanna
# change the cache value elsewhere # change the cache value elsewhere
if tvapi is None: if tvapi is None:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not cache: if not cache:
lINDEXER_API_PARMS['cache'] = False lINDEXER_API_PARMS['cache'] = False
@ -742,7 +740,7 @@ class TVShow(object):
if self.dvdorder != 0: if self.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
else: else:
t = tvapi t = tvapi
@ -1373,7 +1371,7 @@ class TVEpisode(object):
try: try:
if cachedSeason is None: if cachedSeason is None:
if tvapi is None: if tvapi is None:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not cache: if not cache:
lINDEXER_API_PARMS['cache'] = False lINDEXER_API_PARMS['cache'] = False
@ -1384,7 +1382,7 @@ class TVEpisode(object):
if self.show.dvdorder != 0: if self.show.dvdorder != 0:
lINDEXER_API_PARMS['dvdorder'] = True lINDEXER_API_PARMS['dvdorder'] = True
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
else: else:
t = tvapi t = tvapi
myEp = t[self.show.indexerid][season][episode] myEp = t[self.show.indexerid][season][episode]

View File

@ -304,12 +304,12 @@ class TVCache():
# if we have an air-by-date show then get the real season/episode numbers # if we have an air-by-date show then get the real season/episode numbers
if parse_result.air_by_date and indexer_id: if parse_result.air_by_date and indexer_id:
try: try:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
if not (indexer_lang == "" or indexer_lang == "en" or indexer_lang == None): if not (indexer_lang == "" or indexer_lang == "en" or indexer_lang == None):
lINDEXER_API_PARMS['language'] = indexer_lang lINDEXER_API_PARMS['language'] = indexer_lang
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
epObj = t[indexer_id].airedOn(parse_result.air_date)[0] epObj = t[indexer_id].airedOn(parse_result.air_date)[0]
season = int(epObj["seasonnumber"]) season = int(epObj["seasonnumber"])

View File

@ -1599,13 +1599,15 @@ class CMD_SickBeardSearchTVDB(ApiCall):
return _responds(RESULT_SUCCESS, {"results": results, "langid": lang_id}) return _responds(RESULT_SUCCESS, {"results": results, "langid": lang_id})
elif self.indexerid: elif self.indexerid:
lINDEXER_API_PARMS = {'indexer': self.indexer} lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
lang_id = self.valid_languages[self.lang] lang_id = self.valid_languages[self.lang]
if self.lang and not self.lang == 'en': if self.lang and not self.lang == 'en':
lINDEXER_API_PARMS['language'] = self.lang lINDEXER_API_PARMS['language'] = self.lang
t = sickbeard.indexerApi(actors=False, **lINDEXER_API_PARMS) lINDEXER_API_PARMS['actors'] = False
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
try: try:
myShow = t[int(self.indexerid)] myShow = t[int(self.indexerid)]

View File

@ -1976,14 +1976,13 @@ class NewHomeAddShows:
keywords.insert(0, nameUTF8) keywords.insert(0, nameUTF8)
# check for indexer preset # check for indexer preset
indexers = [int(indexer)] indexers = sickbeard.indexerApi.indexers if not int(indexer) else [int(indexer or 0)]
if 0 in indexers:
indexers = sickbeard.indexerApi().indexers
# Query Indexers for each search term and build the list of results # Query Indexers for each search term and build the list of results
for i in indexers: for indexer in indexers():
lINDEXER_API_PARMS = {'indexer': i, 'custom_ui': classes.AllShowsListUI} lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
for searchTerm in keywords: for searchTerm in keywords:
try: try:
@ -1992,11 +1991,10 @@ class NewHomeAddShows:
search = [search] search = [search]
# add search results # add search results
results += [[t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'], results += [[sickbeard.indexerApi(indexer).name, int(sickbeard.indexerApi(indexer).config['id']),
x['firstaired']] for x in search] sickbeard.indexerApi(indexer).config["show_url"], int(x['id']), x['seriesname'],
x['firstaired']] for x in search if x['firstaired']]
except Exception, e: except:continue
continue
# remove duplicates # remove duplicates
results = list(results for results, _ in itertools.groupby(results)) results = list(results for results, _ in itertools.groupby(results))
@ -2068,7 +2066,7 @@ class NewHomeAddShows:
# default to TVDB if indexer was not detected # default to TVDB if indexer was not detected
if show_name and (indexer is None or indexer_id is None): if show_name and (indexer is None or indexer_id is None):
for idx in sickbeard.indexerApi().indexers: for idx in sickbeard.indexerApi.indexers():
found_info = helpers.searchIndexerForShowID(show_name, idx, indexer_id) found_info = helpers.searchIndexerForShowID(show_name, idx, indexer_id)
if found_info: if found_info:
# set indexer and indexer_id from found info # set indexer and indexer_id from found info