1
0
mirror of https://github.com/moparisthebest/SickRage synced 2025-01-05 19:08:02 -05:00

Fix for post-processing and parsing errors.

This commit is contained in:
echel0n 2014-07-06 15:06:19 -07:00
parent dfc600893d
commit f91569ec84
2 changed files with 24 additions and 21 deletions

View File

@ -109,11 +109,11 @@ class NameParser(object):
logger.log(u"WARNING: Invalid show series name pattern, %s: [%s]" % (errormsg, pattern)) logger.log(u"WARNING: Invalid show series name pattern, %s: [%s]" % (errormsg, pattern))
else: else:
# attempt matching with main show name pattern # attempt matching with main show name pattern
seriesname_match = show_regex.match(name) showname_match = show_regex.match(name)
if seriesname_match: if showname_match:
seriesname_groups = seriesname_match.groupdict().keys() showname_groups = showname_match.groupdict().keys()
if 'series_name' in seriesname_groups: if 'show_name' in showname_groups:
series_name = self.clean_series_name(seriesname_match.group('series_name')) series_name = self.clean_series_name(showname_match.group('show_name'))
return helpers.get_show_by_name(series_name, useIndexer=self.useIndexers) return helpers.get_show_by_name(series_name, useIndexer=self.useIndexers)
def _parse_string(self, name): def _parse_string(self, name):
@ -122,15 +122,19 @@ class NameParser(object):
if not self.showObj and not self.naming_pattern: if not self.showObj and not self.naming_pattern:
# Regex pattern to return the Show / Series Name regardless of the file pattern tossed at it, matched 53 show name examples from regexes.py # Regex pattern to return the Show / Series Name regardless of the file pattern tossed at it, matched 53 show name examples from regexes.py
show_pattern = '''(?:(?:\[.*?\])|(?:\d{3}[\.-]))*[ _\.]?(?P<series_name>.*?(?:[ ._-]((?!\d{4}\W\d\d\W\d\d\W)\d{4}))?)(?:(?:(?:[ ._-]+\d+)|(?:[ ._-]+s\d{2}))|(?:\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(?:\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))))''' show_patterns = [
show_pattern_alt = '''^(?P<series_name>.*?(?:[ ._-]((?!\d{4}\W\d\d\W\d\d\W)\d{4}))?)(?:(?:(?:[ ._-]+\d+)|(?:[ ._-]+s\d{2}))|(?:\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(?:\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))))''' '''^(?P<show_name>.*?)\W+(?:(?:S\d[\dE._ -])|(?:\d\d?x)|(?:\d{4}\W\d\d\W\d\d)|(?:(?:part|pt)[\._ -]?(\d|[ivx]))|Season\W+\d+\W+|E\d+\W+|(?:\d{1,3}.+\d{1,}[a-zA-Z]{2}\W+[a-zA-Z]{3,}\W+\d{4}.+))''',
'''^((\[.*?\])|(\d+[\.-]))*[ _\.]*(?P<show_name>.*?)(([ ._-]+\d+)|([ ._-]+s\d{2})).*'''
]
self.showObj = self._matchShowName(name, show_pattern) # find show object
if not self.showObj: for pattern in show_patterns:
self.showObj = self._matchShowName(name, show_pattern_alt) self.showObj = self._matchShowName(name, pattern)
if self.showObj:
if not self.showObj: break
raise InvalidShowException("Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace')) else:
raise InvalidShowException(
"Unable to parse " + name.encode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace'))
regexMode = self.ALL_REGEX regexMode = self.ALL_REGEX
if self.showObj and self.showObj.is_anime: if self.showObj and self.showObj.is_anime:

View File

@ -480,12 +480,11 @@ class PostProcessor(object):
return to_return return to_return
# parse the name to break it into show name, season, and episode # parse the name to break it into show name, season, and episode
try:
np = NameParser(file, useIndexers=True, convert=True) np = NameParser(file, useIndexers=True, convert=True)
parse_result = np.parse(name) parse_result = np.parse(name)
except InvalidShowException:
logger.log(u"Unable to parse the filename " + name + " into a valid show", logger.WARNING) # show object
return to_return show = parse_result.show
if parse_result.air_by_date: if parse_result.air_by_date:
season = -1 season = -1
@ -497,7 +496,7 @@ class PostProcessor(object):
season = parse_result.season_number season = parse_result.season_number
episodes = parse_result.episode_numbers episodes = parse_result.episode_numbers
to_return = (parse_result.show, season, episodes, parse_result.quality) to_return = (show, season, episodes, parse_result.quality)
self._finalize(parse_result) self._finalize(parse_result)
return to_return return to_return
@ -603,7 +602,7 @@ class PostProcessor(object):
try: try:
(cur_show, cur_season, cur_episodes, cur_quality) = cur_attempt() (cur_show, cur_season, cur_episodes, cur_quality) = cur_attempt()
except InvalidNameException, e: except (InvalidNameException, InvalidShowException), e:
logger.log(u"Unable to parse, skipping: " + ex(e), logger.DEBUG) logger.log(u"Unable to parse, skipping: " + ex(e), logger.DEBUG)
continue continue