diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index ad4dddf5..290dc983 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: @@ -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 e4d74a5a..3256d62b 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,33 +157,33 @@ 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 # 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- ((?[^- ]+))?)?$ # Group + -(?P[^- ]+([. _-]\[.*\])?))?)?$ # Group ''' ), + + ('bare', + # Show.Name.102.Source.Quality.Etc-Group + ''' + ^(?P.+?)[. _-]+ # Show_Name and separator + (s)?(?P\d{1,2}) # 1 + (e)?(?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[^- ]+([. _-]\[.*\])?))?)?$ ''' ), 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')