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:
parent
3534574741
commit
8004685d3f
@ -30,7 +30,7 @@
|
||||
#end if
|
||||
<td>
|
||||
<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>
|
||||
#end for
|
||||
</select>
|
||||
|
@ -304,9 +304,9 @@ def searchIndexerForShowID(regShowName, indexer, indexer_id=None):
|
||||
showNames = [re.sub('[. -]', ' ', regShowName), regShowName]
|
||||
|
||||
# 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
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
|
||||
|
||||
for name in showNames:
|
||||
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()
|
||||
|
||||
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:
|
||||
break
|
||||
@ -942,38 +942,23 @@ def get_show_by_name(name, showList, useIndexer=False):
|
||||
return show
|
||||
|
||||
if useIndexer:
|
||||
for indexer in sickbeard.indexerApi().indexers:
|
||||
for indexer in sickbeard.indexerApi.indexers():
|
||||
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['search_all_languages'] = True
|
||||
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
|
||||
showObj = t[name]
|
||||
except (sickbeard.indexer_exception, IOError):
|
||||
# if none found, search on all languages
|
||||
try:
|
||||
lINDEXER_API_PARMS = {'indexer': indexer}
|
||||
except:continue
|
||||
|
||||
lINDEXER_API_PARMS['search_all_languages'] = True
|
||||
lINDEXER_API_PARMS['custom_ui'] = classes.ShowListUI
|
||||
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
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
|
||||
if showObj:
|
||||
showResult = findCertainShow(sickbeard.showList, int(showObj["id"]))
|
||||
if showResult is not None:
|
||||
return showResult
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def suffix(d):
|
||||
return 'th' if 11 <= d <= 13 else {1: 'st', 2: 'nd', 3: 'rd'}.get(d % 10, 'th')
|
||||
|
||||
|
@ -20,28 +20,37 @@ import sickbeard
|
||||
|
||||
from indexer_config import initConfig, indexerConfig
|
||||
|
||||
|
||||
class indexerApi(object):
|
||||
def __init__(self, indexer=None, *args, **kwargs):
|
||||
self._wrapped = object
|
||||
self.config = initConfig
|
||||
self.indexers = {k: v if k is 'id' else v['name'] for k, v in indexerConfig.items()}
|
||||
def __init__(self, indexerID=None):
|
||||
self.indexerID = indexerID
|
||||
|
||||
if indexer in indexerConfig:
|
||||
self.name = indexerConfig[indexer]['name']
|
||||
self.config = indexerConfig[indexer]
|
||||
def indexer(self, *args, **kwargs):
|
||||
if self.indexerID:
|
||||
return indexerConfig[self.indexerID]['module'](*args, **kwargs)
|
||||
|
||||
# set cache if exists
|
||||
if sickbeard.CACHE_DIR: indexerConfig[indexer]['api_params']['cache'] = os.path.join(sickbeard.CACHE_DIR,
|
||||
self.name)
|
||||
# update API params
|
||||
indexerConfig[indexer]['api_params'].update(**kwargs)
|
||||
@property
|
||||
def config(self):
|
||||
if self.indexerID:
|
||||
return indexerConfig[self.indexerID]
|
||||
return initConfig
|
||||
|
||||
# wrap the indexer API object and return it back
|
||||
self._wrapped = indexerConfig[indexer]['module'](*args, **indexerConfig[indexer]['api_params'])
|
||||
@property
|
||||
def name(self):
|
||||
if self.indexerID:
|
||||
return indexerConfig[self.indexerID]['name']
|
||||
|
||||
def __getattr__(self, attr):
|
||||
return getattr(self._wrapped, attr)
|
||||
@property
|
||||
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):
|
||||
return self._wrapped.__getitem__(attr)
|
||||
@property
|
||||
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()}
|
@ -11,91 +11,26 @@ sys.path.append(os.path.abspath('..'))
|
||||
sys.path.append(os.path.abspath('../../../lib'))
|
||||
|
||||
import sickbeard
|
||||
import itertools
|
||||
|
||||
from itertools import chain
|
||||
from sickbeard import classes
|
||||
|
||||
|
||||
class APICheck(unittest.TestCase):
|
||||
indexer = u'3'
|
||||
|
||||
for i in int([indexer]) and sickbeard.indexerApi().indexers:
|
||||
print i
|
||||
|
||||
global indexer, keywords, nameUTF8
|
||||
|
||||
indexer = 0
|
||||
name = 'american dad'
|
||||
indexer_id = 2930
|
||||
lang = "en"
|
||||
|
||||
if not lang or lang == 'null':
|
||||
lang = "en"
|
||||
for indexer in sickbeard.indexerApi.indexers():
|
||||
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')
|
||||
|
||||
# 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
|
||||
season = int(epObj["seasonnumber"])
|
||||
episodes = [int(epObj["episodenumber"])]
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
@ -349,7 +349,7 @@ class GenericMetadata():
|
||||
try:
|
||||
# There's gotta be a better way of doing this but we don't wanna
|
||||
# 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
|
||||
|
||||
@ -359,7 +359,7 @@ class GenericMetadata():
|
||||
if ep_obj.show.dvdorder != 0:
|
||||
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]
|
||||
except sickbeard.indexer_shownotfound, e:
|
||||
@ -739,7 +739,7 @@ class GenericMetadata():
|
||||
try:
|
||||
# There's gotta be a better way of doing this but we don't wanna
|
||||
# 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
|
||||
|
||||
@ -749,7 +749,7 @@ class GenericMetadata():
|
||||
if show_obj.dvdorder != 0:
|
||||
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]
|
||||
except (sickbeard.indexer_error, IOError), e:
|
||||
logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
|
||||
@ -804,7 +804,7 @@ class GenericMetadata():
|
||||
try:
|
||||
# There's gotta be a better way of doing this but we don't wanna
|
||||
# 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
|
||||
|
||||
@ -814,7 +814,7 @@ class GenericMetadata():
|
||||
if show_obj.dvdorder != 0:
|
||||
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]
|
||||
except (sickbeard.indexer_error, IOError), e:
|
||||
logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
|
||||
@ -860,14 +860,14 @@ class GenericMetadata():
|
||||
try:
|
||||
# There's gotta be a better way of doing this but we don't wanna
|
||||
# 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
|
||||
|
||||
if indexer_lang and not indexer_lang == 'en':
|
||||
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]
|
||||
except (sickbeard.indexer_error, IOError), e:
|
||||
logger.log(u"Unable to look up show on " + sickbeard.indexerApi(
|
||||
|
@ -228,7 +228,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
|
||||
indexer_lang = show_obj.lang
|
||||
# There's gotta be a better way of doing this but we don't wanna
|
||||
# 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
|
||||
|
||||
@ -238,7 +238,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
|
||||
if show_obj.dvdorder != 0:
|
||||
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")
|
||||
|
||||
@ -395,7 +395,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
|
||||
indexer_lang = ep_obj.show.lang
|
||||
|
||||
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
|
||||
|
||||
@ -405,7 +405,7 @@ class MediaBrowserMetadata(generic.GenericMetadata):
|
||||
if ep_obj.show.dvdorder != 0:
|
||||
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]
|
||||
except sickbeard.indexer_shownotfound, e:
|
||||
|
@ -166,7 +166,7 @@ class TIVOMetadata(generic.GenericMetadata):
|
||||
indexer_lang = ep_obj.show.lang
|
||||
|
||||
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
|
||||
|
||||
@ -176,7 +176,7 @@ class TIVOMetadata(generic.GenericMetadata):
|
||||
if ep_obj.show.dvdorder != 0:
|
||||
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]
|
||||
except sickbeard.indexer_shownotfound, e:
|
||||
raise exceptions.ShowNotFoundException(str(e))
|
||||
|
@ -177,7 +177,7 @@ class WDTVMetadata(generic.GenericMetadata):
|
||||
indexer_lang = ep_obj.show.lang
|
||||
|
||||
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
|
||||
|
||||
@ -187,7 +187,7 @@ class WDTVMetadata(generic.GenericMetadata):
|
||||
if ep_obj.show.dvdorder != 0:
|
||||
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]
|
||||
except sickbeard.indexer_shownotfound, e:
|
||||
raise exceptions.ShowNotFoundException(e.message)
|
||||
|
@ -97,7 +97,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
|
||||
show_ID = show_obj.indexerid
|
||||
|
||||
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
|
||||
|
||||
@ -107,7 +107,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
|
||||
if show_obj.dvdorder != 0:
|
||||
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")
|
||||
|
||||
@ -221,7 +221,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
|
||||
|
||||
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
|
||||
|
||||
@ -232,7 +232,7 @@ class XBMC_12PlusMetadata(generic.GenericMetadata):
|
||||
lINDEXER_API_PARMS['dvdorder'] = True
|
||||
|
||||
try:
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**lINDEXER_API_PARMS)
|
||||
myShow = t[ep_obj.show.indexerid]
|
||||
except sickbeard.indexer_shownotfound, e:
|
||||
raise exceptions.ShowNotFoundException(e.message)
|
||||
|
@ -284,13 +284,13 @@ class NameParser(object):
|
||||
# see if we can find the name with a TVDB lookup
|
||||
if check_indexer:
|
||||
for cur_name in name_list:
|
||||
for indexer in sickbeard.indexerApi().indexers:
|
||||
for indexer in sickbeard.indexerApi.indexers():
|
||||
try:
|
||||
lINDEXER_API_PARMS = {'indexer': indexer}
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
|
||||
|
||||
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.DEBUG)
|
||||
@ -298,12 +298,12 @@ class NameParser(object):
|
||||
except (sickbeard.indexer_exception):
|
||||
# if none found, search on all languages
|
||||
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['search_all_languages'] = True
|
||||
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
|
||||
|
||||
logger.log(
|
||||
u"Looking up name " + str(cur_name) + " in all languages on " + sickbeard.indexerApi(
|
||||
|
@ -599,12 +599,11 @@ class PostProcessor(object):
|
||||
raise #TODO: later I'll just log this, for now I want to know about it ASAP
|
||||
|
||||
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':
|
||||
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]
|
||||
|
||||
@ -831,7 +830,7 @@ class PostProcessor(object):
|
||||
|
||||
# try to find the file info
|
||||
indexer_id = season = episodes = None
|
||||
for indexer in sickbeard.indexerApi().indexers:
|
||||
for indexer in sickbeard.indexerApi.indexers():
|
||||
self.indexer = int(indexer)
|
||||
|
||||
self._log(u"Searching " + sickbeard.indexerApi(self.indexer).name + ", trying to auto-detect Indexer for "
|
||||
|
@ -169,14 +169,12 @@ class ProperFinder():
|
||||
raise Exception("BAD STUFF HAPPENED")
|
||||
|
||||
indexer_lang = showObj.lang
|
||||
|
||||
lINDEXER_API_PARMS = {'indexer': showObj.indexer}
|
||||
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(showObj.indexer).api_params.copy()
|
||||
if indexer_lang and not indexer_lang == 'en':
|
||||
lINDEXER_API_PARMS['language'] = indexer_lang
|
||||
|
||||
try:
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(showObj.indexer).indexer(**lINDEXER_API_PARMS)
|
||||
|
||||
epObj = t[curProper.indexerid].airedOn(curProper.episode)[0]
|
||||
|
||||
|
@ -73,7 +73,7 @@ def retrieve_exceptions():
|
||||
|
||||
# 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 + "")
|
||||
|
||||
url = sickbeard.indexerApi(indexer).config['scene_url']
|
||||
|
@ -53,8 +53,8 @@ class ShowUpdater():
|
||||
|
||||
# clean out cache directory, remove everything > 12 hours old
|
||||
if sickbeard.CACHE_DIR:
|
||||
for indexer in sickbeard.indexerApi().indexers:
|
||||
cache_dir = sickbeard.indexerApi(indexer).config['api_params']['cache']
|
||||
for indexer in sickbeard.indexerApi.indexers():
|
||||
cache_dir = sickbeard.indexerApi(indexer).cache
|
||||
logger.log(u"Trying to clean cache folder " + cache_dir)
|
||||
|
||||
# Does our cache_dir exists
|
||||
|
@ -240,14 +240,13 @@ class QueueItemAdd(ShowQueueItem):
|
||||
# make sure the indexer ids are valid
|
||||
try:
|
||||
|
||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
||||
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
|
||||
if self.lang:
|
||||
lINDEXER_API_PARMS['language'] = self.lang
|
||||
|
||||
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]
|
||||
|
||||
# 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
|
||||
|
@ -98,10 +98,8 @@ class TVShow(object):
|
||||
|
||||
if ek.ek(os.path.isdir, self._location):
|
||||
return self._location
|
||||
elif self._isDirGood:
|
||||
return self._location
|
||||
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):
|
||||
logger.log(u"Setter sets location to " + newLocation, logger.DEBUG)
|
||||
@ -358,7 +356,7 @@ class TVShow(object):
|
||||
|
||||
scannedEps = {}
|
||||
|
||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
|
||||
|
||||
if self.lang:
|
||||
lINDEXER_API_PARMS['language'] = self.lang
|
||||
@ -366,7 +364,7 @@ class TVShow(object):
|
||||
if self.dvdorder != 0:
|
||||
lINDEXER_API_PARMS['dvdorder'] = True
|
||||
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
|
||||
|
||||
cachedShow = t[self.indexerid]
|
||||
cachedSeasons = {}
|
||||
@ -409,7 +407,7 @@ class TVShow(object):
|
||||
|
||||
def loadEpisodesFromIndexer(self, cache=True):
|
||||
|
||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
|
||||
|
||||
if not cache:
|
||||
lINDEXER_API_PARMS['cache'] = False
|
||||
@ -421,7 +419,7 @@ class TVShow(object):
|
||||
lINDEXER_API_PARMS['dvdorder'] = True
|
||||
|
||||
try:
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
|
||||
showObj = t[self.indexerid]
|
||||
except sickbeard.indexer_error:
|
||||
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 parse_result.air_by_date:
|
||||
try:
|
||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
|
||||
|
||||
if self.lang:
|
||||
lINDEXER_API_PARMS['language'] = self.lang
|
||||
@ -530,7 +528,7 @@ class TVShow(object):
|
||||
if self.dvdorder != 0:
|
||||
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]
|
||||
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
|
||||
# change the cache value elsewhere
|
||||
if tvapi is None:
|
||||
lINDEXER_API_PARMS = {'indexer': self.indexer}
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(self.indexer).api_params.copy()
|
||||
|
||||
if not cache:
|
||||
lINDEXER_API_PARMS['cache'] = False
|
||||
@ -742,7 +740,7 @@ class TVShow(object):
|
||||
if self.dvdorder != 0:
|
||||
lINDEXER_API_PARMS['dvdorder'] = True
|
||||
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
|
||||
|
||||
else:
|
||||
t = tvapi
|
||||
@ -1373,7 +1371,7 @@ class TVEpisode(object):
|
||||
try:
|
||||
if cachedSeason 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:
|
||||
lINDEXER_API_PARMS['cache'] = False
|
||||
@ -1384,7 +1382,7 @@ class TVEpisode(object):
|
||||
if self.show.dvdorder != 0:
|
||||
lINDEXER_API_PARMS['dvdorder'] = True
|
||||
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
t = sickbeard.indexerApi(self.indexer).indexer(**lINDEXER_API_PARMS)
|
||||
else:
|
||||
t = tvapi
|
||||
myEp = t[self.show.indexerid][season][episode]
|
||||
|
@ -304,12 +304,12 @@ class TVCache():
|
||||
# if we have an air-by-date show then get the real season/episode numbers
|
||||
if parse_result.air_by_date and indexer_id:
|
||||
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):
|
||||
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]
|
||||
season = int(epObj["seasonnumber"])
|
||||
|
@ -1599,13 +1599,15 @@ class CMD_SickBeardSearchTVDB(ApiCall):
|
||||
return _responds(RESULT_SUCCESS, {"results": results, "langid": lang_id})
|
||||
|
||||
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]
|
||||
if self.lang and not self.lang == 'en':
|
||||
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:
|
||||
myShow = t[int(self.indexerid)]
|
||||
|
@ -1976,14 +1976,13 @@ class NewHomeAddShows:
|
||||
keywords.insert(0, nameUTF8)
|
||||
|
||||
# check for indexer preset
|
||||
indexers = [int(indexer)]
|
||||
if 0 in indexers:
|
||||
indexers = sickbeard.indexerApi().indexers
|
||||
indexers = sickbeard.indexerApi.indexers if not int(indexer) else [int(indexer or 0)]
|
||||
|
||||
# Query Indexers for each search term and build the list of results
|
||||
for i in indexers:
|
||||
lINDEXER_API_PARMS = {'indexer': i, 'custom_ui': classes.AllShowsListUI}
|
||||
t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
|
||||
for indexer in indexers():
|
||||
lINDEXER_API_PARMS = sickbeard.indexerApi(indexer).api_params.copy()
|
||||
lINDEXER_API_PARMS['custom_ui'] = classes.AllShowsListUI
|
||||
t = sickbeard.indexerApi(indexer).indexer(**lINDEXER_API_PARMS)
|
||||
|
||||
for searchTerm in keywords:
|
||||
try:
|
||||
@ -1992,11 +1991,10 @@ class NewHomeAddShows:
|
||||
search = [search]
|
||||
|
||||
# add search results
|
||||
results += [[t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'],
|
||||
x['firstaired']] for x in search]
|
||||
|
||||
except Exception, e:
|
||||
continue
|
||||
results += [[sickbeard.indexerApi(indexer).name, int(sickbeard.indexerApi(indexer).config['id']),
|
||||
sickbeard.indexerApi(indexer).config["show_url"], int(x['id']), x['seriesname'],
|
||||
x['firstaired']] for x in search if x['firstaired']]
|
||||
except:continue
|
||||
|
||||
# remove duplicates
|
||||
results = list(results for results, _ in itertools.groupby(results))
|
||||
@ -2068,7 +2066,7 @@ class NewHomeAddShows:
|
||||
|
||||
# default to TVDB if indexer was not detected
|
||||
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)
|
||||
if found_info:
|
||||
# set indexer and indexer_id from found info
|
||||
|
Loading…
Reference in New Issue
Block a user