def test_exact_name(self): """SeriesParser: test exact/strict name parsing""" s = SeriesParser() s.name = 'test' s.data = 'Test.Foobar.S01E02.720p-FlexGet' s.parse() assert s.valid, 'normal failed' s = SeriesParser() s.strict_name = True s.name = 'test' s.data = 'Test.A.S01E02.720p-FlexGet' s.parse() assert not s.valid, 'strict A failed' s = SeriesParser() s.strict_name = True s.name = 'Test AB' s.data = 'Test.AB.S01E02.720p-FlexGet' s.parse() assert s.valid, 'strict AB failed' s = SeriesParser() s.strict_name = True s.name = 'Red Tomato' s.data = 'Red Tomato (US) S01E02 720p-FlexGet' s.parse() assert not s.valid, 'Red Tomato (US) should not match Red Tomato in exact mode'
def test_exact_name(self): """SeriesParser: test exact/strict name parsing""" s = SeriesParser() s.name = "test" s.data = "Test.Foobar.S01E02.720p-FlexGet" s.parse() assert s.valid, "normal failed" s = SeriesParser() s.strict_name = True s.name = "test" s.data = "Test.A.S01E02.720p-FlexGet" s.parse() assert not s.valid, "strict A failed" s = SeriesParser() s.strict_name = True s.name = "Test AB" s.data = "Test.AB.S01E02.720p-FlexGet" s.parse() assert s.valid, "strict AB failed" s = SeriesParser() s.strict_name = True s.name = "Red Tomato" s.data = "Red Tomato (US) S01E02 720p-FlexGet" s.parse() assert not s.valid, "Red Tomato (US) should not match Red Tomato in exact mode"
def test_sound_as_ep(self): """SeriesParser: test that sound infos are not picked as ep""" for sound in SeriesParser.sounds: s = SeriesParser() s.name = 'FooBar' s.data = 'FooBar %s XViD-FlexGet' % sound assert_raises(ParseWarning, s.parse)
def test_group_dashes(self): """SeriesParser: group name around extra dashes""" s = SeriesParser() s.name = 'Test' s.data = 'Test.S01E01-FooBar-Group' s.allow_groups = ['xxxx', 'group'] s.parse() assert s.group == 'group', 'did not get group with extra dashes'
def test_from_groups(self): """SeriesParser: test from groups""" s = SeriesParser() s.name = 'Test' s.data = 'Test.S01E01-Group' s.allow_groups = ['xxxx', 'group'] s.parse() assert s.group == 'group', 'did not get group'
def test_from_groups(self): """SeriesParser: test from groups""" s = SeriesParser() s.name = "Test" s.data = "Test.S01E01-Group" s.allow_groups = ["xxxx", "group"] s.parse() assert s.group == "group", "did not get group"
def guess_series(self, title, allow_seasonless=False, quality=None): """Returns a valid series parser if this `title` appears to be a series""" parser = SeriesParser(identified_by='auto', allow_seasonless=allow_seasonless) # We need to replace certain characters with spaces to make sure episode parsing works right # We don't remove anything, as the match positions should line up with the original title clean_title = re.sub('[_.,\[\]\(\):]', ' ', title) if parser.parse_unwanted(clean_title): return match = parser.parse_date(clean_title) if match: parser.identified_by = 'date' else: match = parser.parse_episode(clean_title) if match and parser.parse_unwanted(clean_title): return parser.identified_by = 'ep' if not match: return if match['match'].start() > 1: # We start using the original title here, so we can properly ignore unwanted prefixes. # Look for unwanted prefixes to find out where the series title starts start = 0 prefix = re.match('|'.join(parser.ignore_prefixes), title) if prefix: start = prefix.end() # If an episode id is found, assume everything before it is series name name = title[start:match['match'].start()] # Remove possible episode title from series name (anything after a ' - ') name = name.split(' - ')[0] # Replace some special characters with spaces name = re.sub('[\._\(\) ]+', ' ', name).strip(' -') # Normalize capitalization to title case name = capwords(name) # If we didn't get a series name, return if not name: return parser.name = name parser.data = title try: parser.parse(data=title, quality=quality) except ParseWarning as pw: log.debug('ParseWarning: %s' % pw.value) if parser.valid: return parser
def test_name_with_number(self): """SeriesParser: test number in a name""" s = SeriesParser() s.name = 'Storage 13' s.data = 'Storage 13 no ep number' assert_raises(ParseWarning, s.parse)
def test_invalid_data(self): """SeriesParser: invalid data""" s = SeriesParser() s.name = 'Something Interesting' s.data = 1
def test_invalid_name(self): """SeriesParser: invalid name""" s = SeriesParser() s.name = 1 s.data = 'Something'