Change make indexer lookup optional in NameParser, and deactivate during searches.

This commit is contained in:
Prinz23 2017-07-21 22:34:23 +01:00 committed by JackDandy
parent 01961db505
commit 3e9a9095a6
8 changed files with 17 additions and 14 deletions

View file

@ -74,6 +74,7 @@
* Change improve clarity of various error message by including relevant show name * Change improve clarity of various error message by including relevant show name
* Change extend WEB PROPER release group check to ignore SD releases * Change extend WEB PROPER release group check to ignore SD releases
* Change increase performance by reducing TVDb API requests with a global token * Change increase performance by reducing TVDb API requests with a global token
* Change make indexer lookup optional in NameParser, and deactivate during searches
[develop changelog] [develop changelog]

View file

@ -36,7 +36,7 @@ class NameParser(object):
ANIME_REGEX = 2 ANIME_REGEX = 2
def __init__(self, file_name=True, showObj=None, try_scene_exceptions=False, convert=False, def __init__(self, file_name=True, showObj=None, try_scene_exceptions=False, convert=False,
naming_pattern=False, testing=False): naming_pattern=False, testing=False, indexer_lookup=True):
self.file_name = file_name self.file_name = file_name
self.showObj = showObj self.showObj = showObj
@ -44,6 +44,7 @@ class NameParser(object):
self.convert = convert self.convert = convert
self.naming_pattern = naming_pattern self.naming_pattern = naming_pattern
self.testing = testing self.testing = testing
self.indexer_lookup = indexer_lookup
if self.showObj and not self.showObj.is_anime: if self.showObj and not self.showObj.is_anime:
self._compile_regexes(self.NORMAL_REGEX) self._compile_regexes(self.NORMAL_REGEX)
@ -263,7 +264,7 @@ class NameParser(object):
season_number = int(sql_result[0][0]) season_number = int(sql_result[0][0])
episode_numbers = [int(sql_result[0][1])] episode_numbers = [int(sql_result[0][1])]
if not season_number or not len(episode_numbers): if self.indexer_lookup and not season_number or not len(episode_numbers):
try: try:
lindexer_api_parms = sickbeard.indexerApi(show.indexer).api_params.copy() lindexer_api_parms = sickbeard.indexerApi(show.indexer).api_params.copy()

View file

@ -76,7 +76,7 @@ def _get_proper_list(aired_since_shows, recent_shows, recent_anime):
# for each provider get a list of the # for each provider get a list of the
orig_thread_name = threading.currentThread().name orig_thread_name = threading.currentThread().name
providers = [x for x in sickbeard.providers.sortedProviderList() if x.is_active()] providers = [x for x in sickbeard.providers.sortedProviderList() if x.is_active()]
np = NameParser(False, try_scene_exceptions=True) np = NameParser(False, try_scene_exceptions=True, indexer_lookup=False)
for cur_provider in providers: for cur_provider in providers:
if not recent_anime and cur_provider.anime_only: if not recent_anime and cur_provider.anime_only:
continue continue
@ -103,7 +103,7 @@ def _get_proper_list(aired_since_shows, recent_shows, recent_anime):
name = _generic_name(x.name) name = _generic_name(x.name)
if name not in propers: if name not in propers:
try: try:
np = NameParser(False, try_scene_exceptions=True, showObj=x.parsed_show) np = NameParser(False, try_scene_exceptions=True, showObj=x.parsed_show, indexer_lookup=False)
parse_result = np.parse(x.name) parse_result = np.parse(x.name)
if parse_result.series_name and parse_result.episode_numbers and \ if parse_result.series_name and parse_result.episode_numbers and \
parse_result.show.indexerid in recent_shows + recent_anime: parse_result.show.indexerid in recent_shows + recent_anime:
@ -147,7 +147,7 @@ def _get_proper_list(aired_since_shows, recent_shows, recent_anime):
logger.DEBUG) logger.DEBUG)
continue continue
if not show_name_helpers.pass_wordlist_checks(cur_proper.name, parse=False): if not show_name_helpers.pass_wordlist_checks(cur_proper.name, parse=False, indexer_lookup=False):
logger.log(u'Proper %s isn\'t a valid scene release that we want, ignoring it' % cur_proper.name, logger.log(u'Proper %s isn\'t a valid scene release that we want, ignoring it' % cur_proper.name,
logger.DEBUG) logger.DEBUG)
continue continue

View file

@ -484,7 +484,7 @@ class GenericProvider:
for item in item_list: for item in item_list:
(title, url) = self._title_and_url(item) (title, url) = self._title_and_url(item)
parser = NameParser(False, showObj=self.get_show(item, **kwargs), convert=True) parser = NameParser(False, showObj=self.get_show(item, **kwargs), convert=True, indexer_lookup=False)
# parse the file name # parse the file name
try: try:
parse_result = parser.parse(title) parse_result = parser.parse(title)

View file

@ -95,7 +95,7 @@ class ThePirateBayProvider(generic.TorrentProvider):
return None return None
try: try:
my_parser = NameParser(showObj=self.show) my_parser = NameParser(showObj=self.show, indexer_lookup=False)
parse_result = my_parser.parse(file_name) parse_result = my_parser.parse(file_name)
except (InvalidNameException, InvalidShowException): except (InvalidNameException, InvalidShowException):
return None return None

View file

@ -543,7 +543,8 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
# skip non-tv crap # skip non-tv crap
search_results[cur_ep] = filter( search_results[cur_ep] = filter(
lambda ep_item: show_name_helpers.pass_wordlist_checks( lambda ep_item: show_name_helpers.pass_wordlist_checks(
ep_item.name, parse=False) and ep_item.show == show, search_results[cur_ep]) ep_item.name, parse=False, indexer_lookup=False) and
ep_item.show == show, search_results[cur_ep])
if cur_ep in found_results: if cur_ep in found_results:
found_results[provider_id][cur_ep] += search_results[cur_ep] found_results[provider_id][cur_ep] += search_results[cur_ep]
@ -626,7 +627,7 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
individual_results = filter( individual_results = filter(
lambda r: show_name_helpers.pass_wordlist_checks( lambda r: show_name_helpers.pass_wordlist_checks(
r.name, parse=False) and r.show == show, individual_results) r.name, parse=False, indexer_lookup=False) and r.show == show, individual_results)
for cur_result in individual_results: for cur_result in individual_results:
if 1 == len(cur_result.episodes): if 1 == len(cur_result.episodes):
@ -772,7 +773,7 @@ def search_providers(show, episodes, manual_search=False, torrent_only=False, tr
if name: if name:
if not pass_show_wordlist_checks(name, show): if not pass_show_wordlist_checks(name, show):
continue continue
if not show_name_helpers.pass_wordlist_checks(name): if not show_name_helpers.pass_wordlist_checks(name, indexer_lookup=False):
logger.log('Ignored: %s (debug log has detail)' % name) logger.log('Ignored: %s (debug log has detail)' % name)
continue continue
best_result.name = name best_result.name = name

View file

@ -31,7 +31,7 @@ from sickbeard import encodingKludge as ek
from name_parser.parser import NameParser, InvalidNameException, InvalidShowException from name_parser.parser import NameParser, InvalidNameException, InvalidShowException
def pass_wordlist_checks(name, parse=True): def pass_wordlist_checks(name, parse=True, indexer_lookup=True):
""" """
Filters out non-english and just all-around stupid releases by comparing Filters out non-english and just all-around stupid releases by comparing
the word list contents at boundaries or the end of name. the word list contents at boundaries or the end of name.
@ -44,7 +44,7 @@ def pass_wordlist_checks(name, parse=True):
if parse: if parse:
err_msg = u'Unable to parse the filename %s into a valid ' % name err_msg = u'Unable to parse the filename %s into a valid ' % name
try: try:
NameParser().parse(name) NameParser(indexer_lookup=indexer_lookup).parse(name)
except InvalidNameException: except InvalidNameException:
logger.log(err_msg + 'episode', logger.DEBUG) logger.log(err_msg + 'episode', logger.DEBUG)
return False return False

View file

@ -208,7 +208,7 @@ class TVCache:
return None return None
try: try:
np = NameParser(showObj=showObj, convert=True) np = NameParser(showObj=showObj, convert=True, indexer_lookup=False)
parse_result = np.parse(name) parse_result = np.parse(name)
except InvalidNameException: except InvalidNameException:
logger.log(u'Unable to parse the filename ' + name + ' into a valid episode', logger.DEBUG) logger.log(u'Unable to parse the filename ' + name + ' into a valid episode', logger.DEBUG)
@ -292,7 +292,7 @@ class TVCache:
for curResult in sqlResults: for curResult in sqlResults:
# skip non-tv crap # skip non-tv crap
if not show_name_helpers.pass_wordlist_checks(curResult['name'], parse=False): if not show_name_helpers.pass_wordlist_checks(curResult['name'], parse=False, indexer_lookup=False):
continue continue
# get the show object, or if it's not one of our shows then ignore it # get the show object, or if it's not one of our shows then ignore it