Skip to content

Commit

Permalink
Changed logging around for naming configs, fixed a bug with the multi…
Browse files Browse the repository at this point in the history
…-ep no_season regex
  • Loading branch information
midgetspy committed Oct 19, 2012
1 parent d144554 commit b91ed6b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion sickbeard/name_parser/regexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
'''
^((?P<series_name>.+?)(?:[. _-]{2,}|[. _]))? # Show_Name and separator
(?P<ep_num>\d{1,2}) # 02
(?:-(?P<extra_ep_num>\d{1,2}))? # 02
(?:-(?P<extra_ep_num>\d{1,2}))* # 02
[. _-]+((?P<extra_info>.+?) # Source_Quality_Etc-
((?<![. _-])(?<!WEB) # Make sure this is really the release group
-(?P<release_group>[^- ]+))?)?$ # Group
Expand Down
8 changes: 7 additions & 1 deletion sickbeard/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ def check_valid_naming(pattern=None, multi=None):
if pattern == None:
pattern = sickbeard.NAMING_PATTERN

logger.log(u"Checking whether the pattern "+pattern+" is valid for a single episode", logger.DEBUG)
valid = validate_name(pattern, None)

if multi != None:
logger.log(u"Checking whether the pattern "+pattern+" is valid for a multi episode", logger.DEBUG)
valid = valid and validate_name(pattern, multi)

return valid
Expand All @@ -99,6 +101,7 @@ def check_valid_abd_naming(pattern=None):
if pattern == None:
pattern = sickbeard.NAMING_PATTERN

logger.log(u"Checking whether the pattern "+pattern+" is valid for an air-by-date episode", logger.DEBUG)
valid = validate_name(pattern, abd=True)

return valid
Expand Down Expand Up @@ -126,15 +129,18 @@ def validate_name(pattern, multi=None, file_only=False, abd=False):
logger.log(u"Unable to parse "+new_name+", not valid", logger.DEBUG)
return False

logger.log(new_name + " vs " + str(result), logger.DEBUG)
logger.log("The name "+new_name + " parsed into " + str(result), logger.DEBUG)

if abd:
if result.air_date != ep.airdate:
logger.log(u"Air date incorrect in parsed episode, pattern isn't valid", logger.DEBUG)
return False
else:
if result.season_number != ep.season:
logger.log(u"Season incorrect in parsed episode, pattern isn't valid", logger.DEBUG)
return False
if result.episode_numbers != [x.episode for x in [ep] + ep.relatedEps]:
logger.log(u"Episode incorrect in parsed episode, pattern isn't valid", logger.DEBUG)
return False

return True
Expand Down
7 changes: 4 additions & 3 deletions sickbeard/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,8 +1516,6 @@ def _format_pattern(self, pattern=None, multi=None):
Manipulates an episode naming pattern and then fills the template in
"""

logger.log(u"pattern: "+pattern, logger.DEBUG)

if pattern == None:
pattern = sickbeard.NAMING_PATTERN

Expand Down Expand Up @@ -1621,10 +1619,13 @@ def _format_pattern(self, pattern=None, multi=None):
# fill out the template for this piece and then insert this piece into the actual pattern
cur_name_group_result = re.sub('(?i)(?x)'+regex_used, regex_replacement, cur_name_group)
#cur_name_group_result = cur_name_group.replace(ep_format, ep_string)
logger.log(u"found "+ep_format+" as the ep pattern using "+regex_used+" and replaced it with "+regex_replacement+" to result in "+cur_name_group_result+" from "+cur_name_group, logger.DEBUG)
#logger.log(u"found "+ep_format+" as the ep pattern using "+regex_used+" and replaced it with "+regex_replacement+" to result in "+cur_name_group_result+" from "+cur_name_group, logger.DEBUG)
result_name = result_name.replace(cur_name_group, cur_name_group_result)

result_name = self._format_string(result_name, replace_map)

logger.log(u"formatting pattern: "+pattern+" -> "+result_name, logger.DEBUG)


return result_name

Expand Down
16 changes: 10 additions & 6 deletions tests/name_parser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
('Season 2\\Show Name - 03-04 - Ep Name.ext',
parser.ParseResult(None, 'Show Name', 2, [3,4], extra_info = 'Ep Name'),
['no_season', 'season_only']),

('Season 02\\03-04-05 - Ep Name.ext',
parser.ParseResult(None, None, 2, [3,4,5], extra_info = 'Ep Name'),
['no_season', 'season_only']),
]

unicode_test_cases = [
Expand Down Expand Up @@ -337,11 +341,11 @@ def test_combination_names(self):
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTests)
unittest.TextTestRunner(verbosity=2).run(suite)

#suite = unittest.TestLoader().loadTestsFromTestCase(ComboTests)
#unittest.TextTestRunner(verbosity=2).run(suite)
suite = unittest.TestLoader().loadTestsFromTestCase(ComboTests)
unittest.TextTestRunner(verbosity=2).run(suite)

#suite = unittest.TestLoader().loadTestsFromTestCase(UnicodeTests)
#unittest.TextTestRunner(verbosity=2).run(suite)
suite = unittest.TestLoader().loadTestsFromTestCase(UnicodeTests)
unittest.TextTestRunner(verbosity=2).run(suite)

#suite = unittest.TestLoader().loadTestsFromTestCase(FailureCaseTests)
#unittest.TextTestRunner(verbosity=2).run(suite)
suite = unittest.TestLoader().loadTestsFromTestCase(FailureCaseTests)
unittest.TextTestRunner(verbosity=2).run(suite)

0 comments on commit b91ed6b

Please sign in to comment.