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

New show search code changed to optimize for quicker searches

Increased mainDB version to 28
This commit is contained in:
echel0n 2014-03-25 11:01:21 -07:00
parent e255e44462
commit 872389d055
2 changed files with 13 additions and 36 deletions

View File

@ -27,7 +27,7 @@ from sickbeard import encodingKludge as ek
from sickbeard.name_parser.parser import NameParser, InvalidNameException from sickbeard.name_parser.parser import NameParser, InvalidNameException
MIN_DB_VERSION = 9 # oldest db version we support migrating from MIN_DB_VERSION = 9 # oldest db version we support migrating from
MAX_DB_VERSION = 27 MAX_DB_VERSION = 28
class MainSanityCheck(db.DBSanityCheck): class MainSanityCheck(db.DBSanityCheck):

View File

@ -1982,44 +1982,21 @@ class NewHomeAddShows:
# 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 i in indexers:
def searchShows(): lINDEXER_API_PARMS = {'indexer': i, 'custom_ui': classes.AllShowsListUI}
results = [] t = sickbeard.indexerApi(**lINDEXER_API_PARMS)
lINDEXER_API_PARMS = {'indexer': i, 'custom_ui': classes.AllShowsListUI} for searchTerm in keywords:
t = sickbeard.indexerApi(**lINDEXER_API_PARMS) try:
search = t[searchTerm]
if isinstance(search, dict):
search = [search]
for searchTerm in keywords: # add search results
try: results += [[t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'],
search = t[searchTerm] x['firstaired']] for x in search]
if isinstance(search, dict):
search = [search]
# add search results except Exception, e:
result = [[t.name, t.config['id'], t.config["show_url"], int(x['id']), x['seriesname'], continue
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()
# remove duplicates # remove duplicates
results = list(results for results, _ in itertools.groupby(results)) results = list(results for results, _ in itertools.groupby(results))