diff --git a/CHANGES.md b/CHANGES.md index 0121bca8..d7ad115f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ ### 0.14.0 (2018-xx-xx xx:xx:xx UTC) * Change improve core scheduler logic +* Change improve media process to parse anime format 'Show Name 123 - 001 - Ep 1 name' [develop changelog] diff --git a/sickbeard/name_parser/parser.py b/sickbeard/name_parser/parser.py index 1167c712..97209c50 100644 --- a/sickbeard/name_parser/parser.py +++ b/sickbeard/name_parser/parser.py @@ -113,7 +113,7 @@ class NameParser(object): return matches = [] - + initial_best_result = None for reg_ex in self.compiled_regexes: for (cur_regex_num, cur_regex_name, cur_regex) in self.compiled_regexes[reg_ex]: new_name = helpers.remove_non_release_groups(name, 'anime' in cur_regex_name) @@ -266,6 +266,13 @@ class NameParser(object): # if this is a naming pattern test then return best result if not show or self.naming_pattern: + if not show and not self.naming_pattern and not self.testing: + # ensure anime regex test but use initial best if show still not found + if 0 == reg_ex: + initial_best_result = best_result + matches = [] # clear non-anime match scores + continue + return initial_best_result return best_result # get quality diff --git a/sickbeard/name_parser/regexes.py b/sickbeard/name_parser/regexes.py index d6420e41..21cc9c85 100644 --- a/sickbeard/name_parser/regexes.py +++ b/sickbeard/name_parser/regexes.py @@ -302,15 +302,15 @@ anime_regexes = [ # Bleach s16e03e04 313-314 ''' ^(\[(?P.+?)\][ ._-]*)? - (?P.+?)[ ._-]+ # start of string and series name and non optinal separator + (?P.+?)[ ._-]+ # start of string and series name and non optional separator [sS](?P\d+)[. _-]* # S01 and optional separator - [eE](?P\d+) # epipisode E02 + [eE](?P\d+) # episode E02 (([. _-]*e|-) # linking e/- char (?P\d+))* # additional E03/etc ([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be # there(->{2,}) "s16e03-04-313-314" would make sens any way - (?P\d{1,3}) # absolute number - (-(?P\d{1,3}))* # "-" as separator and anditional absolute number, all optinal + (?\d{1,3})(?!0p) # absolute number + (-(?P\d{1,3}))* # "-" as separator and additional absolute number, all optional (v(?P[0-9]))? # the version e.g. "v2" .*? ''' @@ -321,15 +321,15 @@ anime_regexes = [ # Bleach.s16e03-04.313-314 # Bleach s16e03e04 313-314 ''' - ^(?P.+?)[ ._-]+ # start of string and series name and non optinal separator + ^(?P.+?)[ ._-]+ # start of string and series name and non optional separator (?P\d+)[. _-]* # S01 and optional separator - [xX](?P\d+) # epipisode E02 + [xX](?P\d+) # episode E02 (([. _-]*e|-) # linking e/- char (?P\d+))* # additional E03/etc ([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be # there(->{2,}) "s16e03-04-313-314" would make sens any way - (?P\d{1,3}) # absolute number - (-(?P\d{1,3}))* # "-" as separator and anditional absolute number, all optinal + (?\d{1,3})(?!0p) # absolute number + (-(?P\d{1,3}))* # "-" as separator and additional absolute number, all optional (v(?P[0-9]))? # the version e.g. "v2" .*? ''' @@ -338,14 +338,14 @@ anime_regexes = [ ('anime_and_normal_reverse', # Bleach - 313-314 - s16e03-04 ''' - ^(?P.+?)[ ._-]+ # start of string and series name and non optinal separator - (?P\d{1,3}) # absolute number - (-(?P\d{1,3}))* # "-" as separator and anditional absolute number, all optinal + ^(?P.+?)[ ._-]+ # start of string and series name and non optional separator + (?\d{1,3})(?!0p) # absolute number + (-(?P\d{1,3}))* # "-" as separator and additional absolute number, all optional (v(?P[0-9]))? # the version e.g. "v2" ([ ._-]{2,}|[ ._]+) # if "-" is used to separate at least something else has to be # there(->{2,}) "s16e03-04-313-314" would make sens any way [sS](?P\d+)[. _-]* # S01 and optional separator - [eE](?P\d+) # epipisode E02 + [eE](?P\d+) # episode E02 (([. _-]*e|-) # linking e/- char (?P\d+))* # additional E03/etc .*? @@ -355,8 +355,8 @@ anime_regexes = [ ('anime_and_normal_front', # 165.Naruto Shippuuden.s08e014 ''' - ^(?P\d{1,3}) # start of string and absolute number - (-(?P\d{1,3}))* # "-" as separator and anditional absolute number, all optinal + ^(?\d{1,3})(?!0p) # start of string and absolute number + (-(?P\d{1,3}))* # "-" as separator and additional absolute number, all optional (v(?P[0-9]))?[ ._-]+ # the version e.g. "v2" (?P.+?)[ ._-]+ [sS](?P\d+)[. _-]* # S01 and optional separator @@ -371,7 +371,7 @@ anime_regexes = [ ''' ^(?:\[(?P.+?)\][ ._-]*) (?P.+?)[ ._-]+ - (?P\d{1,3}) + (?\d{1,3})(?!0p) (-(?P\d{1,3}))*[ ._-]*? (?:v(?P[0-9])[ ._-]+?)? (?:.+?[ ._-]+?)? @@ -381,8 +381,19 @@ anime_regexes = [ ''' ), - ('anime_bare', + ('anime_bare_ep', # One Piece - 102 + # Show Name 123 - 001 + ''' + ^(?:\[(?P.+?)\][ ._-]*)? + (?P.+?)[ ._-]+[ ._-]{2,} # Show_Name and min 2 char separator + (?\d{1,3})(?!0p) # 1/001, while avoiding H.264 and 1080p from being matched + (-(?P\d{1,3}))*[ ._-]* # 2/002 + (?:v(?P[0-9]))? # v2 + ''' + ), + + ('anime_bare', # [ACX]_Wolf's_Spirit_001.mkv ''' ^(\[(?P.+?)\][ ._-]*)? diff --git a/tests/name_parser_tests.py b/tests/name_parser_tests.py index 894828a4..cfee7160 100644 --- a/tests/name_parser_tests.py +++ b/tests/name_parser_tests.py @@ -271,10 +271,14 @@ simple_test_cases = { '165-166.3x3 Eyes.S08E014E015': parser.ParseResult(None, '3x3 Eyes', 8, [14, 15], None, None, None, [165, 166]), }, - 'anime_bare': { + 'anime_bare_ep': { + 'Show Name 123 - 001 - Ep 1 name': parser.ParseResult(None, 'Show Name 123', None, [], None, None, None, [1]), 'One Piece 102': parser.ParseResult(None, 'One Piece', None, [], None, None, None, [102]), 'bleach - 010': parser.ParseResult(None, 'bleach', None, [], None, None, None, [10]), 'Naruto Shippuden - 314v2': parser.ParseResult(None, 'Naruto Shippuden', None, [], None, None, None, [314]), + }, + + 'anime_bare': { 'Blue Submarine No. 6 104-105': parser.ParseResult(None, 'Blue Submarine No. 6', None, [], None, None, None, [104, 105]), 'Samurai X: Trust & Betrayal (OVA) 001-002': @@ -559,6 +563,10 @@ class BasicTests(test.SickbeardTestDBCase): np = parser.NameParser(False, TVShow(is_anime=True), testing=True) self._test_names(np, 'anime_and_normal_front') + def test_anime_bare_ep(self): + np = parser.NameParser(False, TVShow(is_anime=True), testing=True) + self._test_names(np, 'anime_bare_ep') + def test_anime_bare(self): np = parser.NameParser(False, TVShow(is_anime=True), testing=True) self._test_names(np, 'anime_bare')