From f16ee09501b650b6ed04f30da594baa45ee927db Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 24 Jun 2014 18:42:03 -0700 Subject: [PATCH] Updated regex for show series name matching, faster matching. --- sickbeard/name_parser/parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index f8e8872b..0cc8bc7f 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -110,7 +110,7 @@ class NameParser(object): 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 - show_pattern = '''((\[.*?\])|(\d+[\.-]))*[ _\.]?(?P.*?([ ._-](\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_pattern = '''(?:(?:\[.*?\])|(?:\d{3}[\.-]))*[ _\.]?(?P.*?(?:[ ._-](\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}.+))))''' try: show_regex = re.compile(show_pattern, re.VERBOSE | re.IGNORECASE) except re.error, errormsg: @@ -125,6 +125,9 @@ class NameParser(object): # Do we have recognize this show? series_name = self.clean_series_name(seriesname_match.group('series_name')) self.showObj = helpers.get_show_by_name(series_name, useIndexer=self.useIndexers) + if not self.showObj: + series_name = re.sub('^(?:(?:\[.*?\])|(?:\d{3}[\.-]))*[ _\.]?', '', series_name) + self.showObj = helpers.get_show_by_name(series_name, useIndexer=self.useIndexers) if not self.showObj: return