Skip to content

Commit

Permalink
Fix the name parser for certain no-season episode names
Browse files Browse the repository at this point in the history
  • Loading branch information
midgetspy committed Jan 19, 2011
1 parent 13a44d9 commit d3fce8b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
42 changes: 27 additions & 15 deletions sickbeard/name_parser/regexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,6 @@
(?P<ep_num>\d{2})$ # 02
'''),

('bare',
# Show.Name.102.Source.Quality.Etc-Group
'''
^(?P<series_name>.+?)[. _-]+ # Show_Name and separator
(?P<season_num>\d{1,2}) # 1
(?P<ep_num>\d{2}) # 02 and separator
([. _-]+(?P<extra_info>(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc-
(-(?P<release_group>.+))?)?$ # Group
'''),

('verbose',
# Show Name Season 1 Episode 2 Ep Name
'''
Expand All @@ -129,24 +119,46 @@
'''
),

('no_season_multi_ep',
# Show.Name.E02-03
# Show.Name.E02.2010
'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
(e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part
(?P<ep_num>(\d+|[ivx]+)) # first ep num
((([. _-]+(and|&|to)[. _-]+)|-) # and/&/to joiner
(?P<extra_ep_num>(?!(1080|720)[pi])(\d+|[ivx]+))[. _-]) # second ep num
([. _-]*(?P<extra_info>.+?) # Source_Quality_Etc-
((?<![. _-])-(?P<release_group>[^-]+))?)?$ # Group
'''
),

('no_season_general',
# Show.Name.E23.Test
# Show.Name.Part.3.Source.Quality.Etc-Group
# Show.Name.Part.1.and.Part.2.Blah-Group
# Show Name Episode 3 and 4
'''
^((?P<series_name>.+?)[. _-]+)? # Show_Name and separator
(e(p(isode)?)?|part|pt)[. _-]? # e, ep, episode, or part
(?P<ep_num>(\d+|[ivx]+)) # first ep num
([. _-]+((and|&|to)[. _-]+)? # and/&/to joiner
((e(p(isode)?)?|part|pt)[. _-]?)? # e, ep, episode, or part
(?P<extra_ep_num>(?!(1080|720)[pi])(\d+|[ivx]+)))* # second ep num
[. _-]*((?P<extra_info>.+?) # Source_Quality_Etc-
((e(p(isode)?)?|part|pt)[. _-]?) # e, ep, episode, or part
(?P<extra_ep_num>(?!(1080|720)[pi])(\d+|[ivx]+))[. _-])* # second ep num
([. _-]*(?P<extra_info>.+?) # Source_Quality_Etc-
((?<![. _-])-(?P<release_group>[^-]+))?)?$ # Group
'''
),


('bare',
# Show.Name.102.Source.Quality.Etc-Group
'''
^(?P<series_name>.+?)[. _-]+ # Show_Name and separator
(?P<season_num>\d{1,2}) # 1
(?P<ep_num>\d{2}) # 02 and separator
([. _-]+(?P<extra_info>(?!\d{3}[. _-]+)[^-]+) # Source_Quality_Etc-
(-(?P<release_group>.+))?)?$ # Group
'''),

('no_season',
# Show Name - 01 - Ep Name
# 01 - Ep Name
Expand Down
15 changes: 14 additions & 1 deletion tests/name_parser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import sys, os.path
sys.path.append(os.path.abspath('..'))
sys.path.append(os.path.abspath('../lib'))

from sickbeard.name_parser import parser

Expand Down Expand Up @@ -71,10 +72,14 @@
'Show Name - Episode 01 - Ep Name': parser.ParseResult(None, 'Show Name', None, [1], 'Ep Name'),
'Show.Name.Part.3.Source.Quality.Etc-Group': parser.ParseResult(None, 'Show Name', None, [3], 'Source.Quality.Etc', 'Group'),
'Show.Name.Part.1.and.Part.2.Blah-Group': parser.ParseResult(None, 'Show Name', None, [1,2], 'Blah', 'Group'),
'Show Name Episode 3 and 4': parser.ParseResult(None, 'Show Name', None, [3,4]),
'Show.Name.Part.IV.Source.Quality.Etc-Group': parser.ParseResult(None, 'Show Name', None, [4], 'Source.Quality.Etc', 'Group'),
},

'no_season_multi_ep': {
'Show.Name.E23-24.Source.Quality.Etc-Group': parser.ParseResult(None, 'Show Name', None, [23,24], 'Source.Quality.Etc', 'Group'),
'Show Name - Episode 01-02 - Ep Name': parser.ParseResult(None, 'Show Name', None, [1,2], 'Ep Name'),
},

'season_only': {
'Show.Name.S02.Source.Quality.Etc-Group': parser.ParseResult(None, 'Show Name', 2, [], 'Source.Quality.Etc', 'Group'),
'Show Name Season 2': parser.ParseResult(None, 'Show Name', 2),
Expand Down Expand Up @@ -219,6 +224,10 @@ def test_no_season_general_names(self):
np = parser.NameParser(False)
self._test_names(np, 'no_season_general')

def test_no_season_multi_ep_names(self):
np = parser.NameParser(False)
self._test_names(np, 'no_season_multi_ep')

def test_season_only_names(self):
np = parser.NameParser(False)
self._test_names(np, 'season_only')
Expand Down Expand Up @@ -259,6 +268,10 @@ def test_no_season_general_file_names(self):
np = parser.NameParser()
self._test_names(np, 'no_season_general', lambda x: x + '.avi')

def test_no_season_multi_ep_file_names(self):
np = parser.NameParser()
self._test_names(np, 'no_season_multi_ep', lambda x: x + '.avi')

def test_season_only_file_names(self):
np = parser.NameParser()
self._test_names(np, 'season_only', lambda x: x + '.avi')
Expand Down

0 comments on commit d3fce8b

Please sign in to comment.