Skip to content

Commit

Permalink
Added "limited extend" and "separated repeat" multi naming styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
midgetspy committed Jun 9, 2012
1 parent 6890143 commit b4d1c57
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions sickbeard/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@
NAMING_REPEAT = 1
NAMING_EXTEND = 2
NAMING_DUPLICATE = 4
NAMING_LIMITED_EXTEND = 8
NAMING_SEPARATED_REPEAT = 16

multiEpStrings = {}
multiEpStrings[NAMING_REPEAT] = "Repeat"
multiEpStrings[NAMING_SEPARATED_REPEAT] = "Separated Repeat"
multiEpStrings[NAMING_DUPLICATE] = "Duplicate"
multiEpStrings[NAMING_EXTEND] = "Extend"
multiEpStrings[NAMING_LIMITED_EXTEND] = "Limited Extend"

class Quality:

Expand Down
11 changes: 9 additions & 2 deletions sickbeard/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,19 @@ def _generate_sample_ep(multi=None, abd=False):

if multi != None:
ep._name = "Ep Name (1)"
ep._release_name = 'Show.Name.S02E03E04E05.HDTV.XviD-RLSGROUP'

secondEp = TVEpisode(2,4,"Ep Name (2)")
secondEp._status = Quality.compositeStatus(DOWNLOADED, Quality.HDTV)
ep.relatedEps.append(secondEp)
ep._release_name = 'Show.Name.S02E03E04.HDTV.XviD-RLSGROUP'
secondEp._release_name = ep._release_name

thirdEp = TVEpisode(2,5,"Ep Name (3)")
thirdEp._status = Quality.compositeStatus(DOWNLOADED, Quality.HDTV)
thirdEp._release_name = ep._release_name

ep.relatedEps.append(secondEp)
ep.relatedEps.append(thirdEp)

return ep

def test_name(pattern, multi=None, abd=False):
Expand Down
15 changes: 12 additions & 3 deletions sickbeard/tv.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

from common import Quality, Overview
from common import DOWNLOADED, SNATCHED, SNATCHED_PROPER, ARCHIVED, IGNORED, UNAIRED, WANTED, SKIPPED, UNKNOWN
from common import NAMING_DUPLICATE, NAMING_EXTEND
from common import NAMING_DUPLICATE, NAMING_EXTEND, NAMING_LIMITED_EXTEND, NAMING_SEPARATED_REPEAT

class TVShow(object):

Expand Down Expand Up @@ -1538,7 +1538,7 @@ def _format_pattern(self, pattern=None, multi=None):
sep = ' '

# force 2-3-4 format if they chose to extend
if multi == NAMING_EXTEND:
if multi in (NAMING_EXTEND, NAMING_LIMITED_EXTEND):
ep_sep = '-'

regex_used = season_ep_regex
Expand All @@ -1561,9 +1561,18 @@ def _format_pattern(self, pattern=None, multi=None):
# start with the ep string, eg. E03
ep_string = self._format_string(ep_format.upper(), replace_map)
for other_ep in self.relatedEps:
if multi == NAMING_DUPLICATE:

# for limited extend we only append the last ep
if multi == NAMING_LIMITED_EXTEND and other_ep != self.relatedEps[-1]:
continue

elif multi == NAMING_DUPLICATE:
# add " - S01"
ep_string += sep + season_format

elif multi == NAMING_SEPARATED_REPEAT:
ep_string += sep

# add "E04"
ep_string += ep_sep
ep_string += other_ep._format_string(ep_format.upper(), other_ep._replace_map())
Expand Down

0 comments on commit b4d1c57

Please sign in to comment.