From 65eda93b2b7ea4b9629f50cdd12f808a61437ed1 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 6 Sep 2014 17:25:07 -0700 Subject: [PATCH] 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 --- sickbeard/properFinder.py | 2 +- sickbeard/search.py | 21 ++------------------- sickbeard/show_name_helpers.py | 5 +++-- sickbeard/tvcache.py | 2 +- 4 files changed, 7 insertions(+), 23 deletions(-) diff --git a/sickbeard/properFinder.py b/sickbeard/properFinder.py index d4911c6a..4f21b5ae 100644 --- a/sickbeard/properFinder.py +++ b/sickbeard/properFinder.py @@ -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 diff --git a/sickbeard/search.py b/sickbeard/search.py index f9b651a4..4b70ee9c 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -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: diff --git a/sickbeard/show_name_helpers.py b/sickbeard/show_name_helpers.py index 1685d9e4..765890f6 100644 --- a/sickbeard/show_name_helpers.py +++ b/sickbeard/show_name_helpers.py @@ -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 diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index 1dd52d49..6326cca7 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -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