Fixed high CPU usage during searches, adding conditional check to prevent un-needed name parsing of search results when search result was previously already parsed and checked during filtering of bad releases

This commit is contained in:
echel0n 2014-09-06 17:25:07 -07:00
parent 4af28657af
commit 65eda93b2b
4 changed files with 7 additions and 23 deletions

View file

@ -149,7 +149,7 @@ class ProperFinder():
logger.DEBUG)
continue
if not show_name_helpers.filterBadReleases(curProper.name):
if not show_name_helpers.filterBadReleases(curProper.name, parse=False):
logger.log(u"Proper " + curProper.name + " isn't a valid scene release that we want, ignoring it",
logger.DEBUG)
continue

View file

@ -319,23 +319,6 @@ def isFirstBestMatch(result):
return False
def filterSearchResults(show, season, results):
foundResults = {}
# make a list of all the results for this provider
for curEp in results:
# skip non-tv crap
results[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name) and x.show == show,results[curEp])
if curEp in foundResults:
foundResults[curEp] += results[curEp]
else:
foundResults[curEp] = results[curEp]
return foundResults
def searchForNeededEpisodes():
foundResults = {}
@ -468,7 +451,7 @@ def searchProviders(show, season, episodes, manualSearch=False):
for curEp in searchResults:
# skip non-tv crap
searchResults[curEp] = filter(
lambda x: show_name_helpers.filterBadReleases(x.name) and x.show == show, searchResults[curEp])
lambda x: show_name_helpers.filterBadReleases(x.name, parse=False) and x.show == show, searchResults[curEp])
if curEp in foundResults:
foundResults[curProvider.name][curEp] += searchResults[curEp]
@ -554,7 +537,7 @@ def searchProviders(show, season, episodes, manualSearch=False):
individualResults = nzbSplitter.splitResult(bestSeasonResult)
individualResults = filter(
lambda x: show_name_helpers.filterBadReleases(x.name) and x.show == show, individualResults)
lambda x: show_name_helpers.filterBadReleases(x.name, parse=False) and x.show == show, individualResults)
for curResult in individualResults:
if len(curResult.episodes) == 1:

View file

@ -36,7 +36,7 @@ resultFilters = ["sub(bed|ed|pack|s)", "(dk|fin|heb|kor|nor|nordic|pl|swe)sub(be
"(dir|sample|sub|nfo)fix", "sample", "(dvd)?extras",
"dub(bed)?"]
def filterBadReleases(name):
def filterBadReleases(name, parse=True):
"""
Filters out non-english and just all-around stupid releases by comparing them
to the resultFilters contents.
@ -47,7 +47,8 @@ def filterBadReleases(name):
"""
try:
NameParser().parse(name)
if parse:
NameParser().parse(name)
except InvalidNameException:
logger.log(u"Unable to parse the filename " + name + " into a valid episode", logger.DEBUG)
return False

View file

@ -309,7 +309,7 @@ class TVCache():
for curResult in sqlResults:
# skip non-tv crap
if not show_name_helpers.filterBadReleases(curResult["name"]):
if not show_name_helpers.filterBadReleases(curResult["name"], parse=False):
continue
# get the show object, or if it's not one of our shows then ignore it