From 5c5b6f49e1a89090c46cc43bf7b908ceca8da2cd Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 23 Jun 2014 23:45:21 -0700 Subject: [PATCH 1/4] Fixed regex patterns for both show and release names. Fixed post-processing loop issue. --- sickbeard/name_parser/parser.py | 2 +- sickbeard/name_parser/regexes.py | 40 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index ad4dddf5..ac353d08 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -109,7 +109,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 = '''^(?:(UEFA|MLB|ESPN|WWE|MMA|UFC|TNA|EPL|NASCAR|NBA|NFL|NHL|NRL|PGA|SUPER LEAGUE|FORMULA|FIFA|NETBALL|MOTOG(P)))?(?:[0-9]+)?(?:\[(?:.+?)\][ ._-])?(?P.*?)(?:[ ._-])+?(?:Season|Part)?(?:.[eE][0-9][0-9]?)?(?:.?[sS]?[0-9][0-9]?)''' + 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}.+))))''' try: show_regex = re.compile(show_pattern, re.VERBOSE | re.IGNORECASE) except re.error, errormsg: diff --git a/sickbeard/name_parser/regexes.py b/sickbeard/name_parser/regexes.py index e4d74a5a..2816b3e3 100644 --- a/sickbeard/name_parser/regexes.py +++ b/sickbeard/name_parser/regexes.py @@ -30,7 +30,7 @@ normal_regexes = {'normal':[ e(?P\d+))+ # E03/etc and separator [. _-]*((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('fov_repeat', @@ -44,7 +44,7 @@ normal_regexes = {'normal':[ (?P\d+))+ # 03/etc and separator [. _-]*((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('standard', @@ -62,7 +62,7 @@ normal_regexes = {'normal':[ (?P(?!(1080|720|480)[pi])\d+))* # additional E03/etc [. _-]*((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('fov', @@ -80,7 +80,7 @@ normal_regexes = {'normal':[ \d+))* # additional x03/etc [\]. _-]*((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('scene_date_format', @@ -93,7 +93,7 @@ normal_regexes = {'normal':[ (?P\d{2}) # 23 and separator [. _-]*((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ('stupid', @@ -124,7 +124,7 @@ normal_regexes = {'normal':[ (?P\d+)[. _-]* # S01 and optional separator [. _-]*((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), @@ -139,7 +139,7 @@ normal_regexes = {'normal':[ (?P(?!(1080|720|480)[pi])(\d+|[ivx]+))[. _-]) # second ep num ([. _-]*(?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), @@ -157,20 +157,10 @@ normal_regexes = {'normal':[ (\d+|([ivx]+(?=[. _-]))))[. _-])* # second ep num ([. _-]*(?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), - ('bare', - # Show.Name.102.Source.Quality.Etc-Group - ''' - ^(?P.+?)[. _-]+ # Show_Name and separator - (?P\d{1,2}) # 1 - (?P\d{2}) # 02 and separator - ([. _-]+(?P(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc- - (-(?P.+))?)?$ # Group - '''), - ('no_season', # Show Name - 01 - Ep Name # 01 - Ep Name @@ -181,9 +171,19 @@ normal_regexes = {'normal':[ (?:-(?P\d{1,2}))* # 02 [. _-]+((?P.+?) # Source_Quality_Etc- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), + + ('bare', + # Show.Name.102.Source.Quality.Etc-Group + ''' + ^(?P.+?)[. _-]+ # Show_Name and separator + (?P\d{1,2}) # 1 + (?P\d{2}) # 02 and separator + ([. _-]+(?P(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc- + (-(?P.+))?)?$ # Group + '''), ]} sports_regexs = {'sports':[ @@ -210,7 +210,7 @@ sports_regexs = {'sports':[ ((?P\.+)[. _-]+)? (?P(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4})) [. _-]*((?P.+?)((?[^- ]+))?)?$ + -(?P[^- ]+([. _-]\[.*\])?))?)?$ ''' ), From fcd54c93d6a6482f0e0f8daeea964ee4f7b45f1b Mon Sep 17 00:00:00 2001 From: echel0n Date: Mon, 23 Jun 2014 23:59:08 -0700 Subject: [PATCH 2/4] Fixed minor regex mistake in code. --- sickbeard/name_parser/parser.py | 2 +- sickbeard/name_parser/regexes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index ac353d08..290dc983 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -243,7 +243,7 @@ class NameParser(object): matches.append(result) if len(matches): - result = max(matches, key=lambda x: x.score) + result = max(sorted(matches, reverse=True), key=lambda x: x.score) if result.show: if self.convert and not self.naming_pattern: diff --git a/sickbeard/name_parser/regexes.py b/sickbeard/name_parser/regexes.py index 2816b3e3..62b16bc4 100644 --- a/sickbeard/name_parser/regexes.py +++ b/sickbeard/name_parser/regexes.py @@ -182,7 +182,7 @@ normal_regexes = {'normal':[ (?P\d{1,2}) # 1 (?P\d{2}) # 02 and separator ([. _-]+(?P(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc- - (-(?P.+))?)?$ # Group + (-(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''), ]} From 5f0265e769901f438b68ac4b18d2c9a320974dcb Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 24 Jun 2014 00:06:39 -0700 Subject: [PATCH 3/4] Fixed post-processing loop issue. --- sickbeard/processTV.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sickbeard/processTV.py b/sickbeard/processTV.py index c02d2d73..615a6cd1 100644 --- a/sickbeard/processTV.py +++ b/sickbeard/processTV.py @@ -352,6 +352,7 @@ def already_postprocessed(dirName, videofile, force): logger.DEBUG) return True + else: # This is needed for video whose name differ from dirName if not isinstance(videofile, unicode): videofile = unicode(videofile, 'utf_8') From cec01405d84ec196a942a1039923653c3c95d7d3 Mon Sep 17 00:00:00 2001 From: echel0n Date: Tue, 24 Jun 2014 00:42:13 -0700 Subject: [PATCH 4/4] Fix for release results x264 issue --- sickbeard/name_parser/regexes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sickbeard/name_parser/regexes.py b/sickbeard/name_parser/regexes.py index 62b16bc4..3256d62b 100644 --- a/sickbeard/name_parser/regexes.py +++ b/sickbeard/name_parser/regexes.py @@ -167,7 +167,7 @@ normal_regexes = {'normal':[ # 01 - Ep Name ''' ^((?P.+?)(?:[. _-]{2,}|[. _]))? # Show_Name and separator - (?P\d{1,2}) # 02 + (e)?(?P\d{1,2}) # 02 (?:-(?P\d{1,2}))* # 02 [. _-]+((?P.+?) # Source_Quality_Etc- ((?.+?)[. _-]+ # Show_Name and separator - (?P\d{1,2}) # 1 - (?P\d{2}) # 02 and separator + (s)?(?P\d{1,2}) # 1 + (e)?(?P\d{2}) # 02 and separator ([. _-]+(?P(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc- (-(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group '''),