1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Added ability for format anime naming from post-processing options.

Fixed regex issues for anime shows matching 720p as a absolute number.
Custom sports naming has been fixed to adhere to dates.
This commit is contained in:
echel0n 2014-06-07 01:17:12 -07:00
parent 08159e2872
commit 1e8f3e2883
8 changed files with 212 additions and 92 deletions

View File

@ -269,10 +269,8 @@
</div>
#end for
<div class="clearfix" style="clear:left;"></div><br/>
<input type="submit" class="btn config_submitter" value="Save Changes" /><br/>
<div class="clearfix" style="clear:left;"></div><br/>
<input type="submit" class="btn config_submitter" value="Save Changes" /><br/>
</fieldset>
</div><!-- /component-group2 //-->
@ -292,7 +290,7 @@
<select id="name_presets">
#set is_custom = True
#for $cur_preset in $naming.name_presets:
#set $tmp = $naming.test_name($cur_preset)
#set $tmp = $naming.test_name($cur_preset, anime_type=3)
#if $cur_preset == $sickbeard.NAMING_PATTERN:
#set is_custom = False
#end if
@ -452,7 +450,7 @@
</div>
<div id="naming_example_div">
<h2>Sample:</h2>
<h2>Single-EP Sample:</h2>
<div class="example">
<span class="jumbo" id="naming_example">&nbsp;</span>
</div>
@ -467,8 +465,24 @@
<br/>
</div>
<div id="naming_example_anime_div">
<h2>Single-EP Anime Sample:</h2>
<div class="example">
<span class="jumbo" id="naming_example_anime">&nbsp;</span>
</div>
<br/>
</div>
<div id="naming_example_multi_anime_div">
<h2>Multi-EP Anime sample:</h2>
<div class="example">
<span class="jumbo" id="naming_example_multi_anime">&nbsp;</span>
</div>
<br/>
</div>
<div class="field-pair">
<input type="radio" name="naming_anime" id="naming_anime" value="1" #if $sickbeard.NAMING_ANIME == 1then "checked=\"checked\"" else ""#/>
<input type="radio" name="naming_anime" id="naming_anime" value="1" #if $sickbeard.NAMING_ANIME == 1 then "checked=\"checked\"" else ""#/>
<label class="clearfix" for="naming_anime">
<span class="component-title">Add Absolute Number</span>
<span class="component-desc">Add the absolute number to the season/episode format?</span>

View File

@ -29,8 +29,9 @@ $(document).ready(function () {
function fill_examples() {
var pattern = $('#naming_pattern').val();
var multi = $('#naming_multi_ep :selected').val();
var anime_type = $('input[name="naming_anime"]:checked').val();
$.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern},
$.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern, anime_type: 3},
function (data) {
if (data) {
$('#naming_example').text(data + '.ext');
@ -40,7 +41,7 @@ $(document).ready(function () {
}
});
$.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern, multi: multi},
$.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern, multi: multi, anime_type: 3},
function (data) {
if (data) {
$('#naming_example_multi').text(data + '.ext');
@ -50,7 +51,27 @@ $(document).ready(function () {
}
});
$.get(sbRoot + '/config/postProcessing/isNamingValid', {pattern: pattern, multi: multi},
$.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern, anime_type: anime_type},
function (data) {
if (data) {
$('#naming_example_anime').text(data + '.ext');
$('#naming_example_anime_div').show();
} else {
$('#naming_example_anime_div').hide();
}
});
$.get(sbRoot + '/config/postProcessing/testNaming', {pattern: pattern, multi: multi, anime_type: anime_type},
function (data) {
if (data) {
$('#naming_example_multi_anime').text(data + '.ext');
$('#naming_example_multi_anime_div').show();
} else {
$('#naming_example_multi_anime_div').hide();
}
});
$.get(sbRoot + '/config/postProcessing/isNamingValid', {pattern: pattern, multi: multi, anime_type: anime_type},
function (data) {
if (data == "invalid") {
$('#naming_pattern').qtip('option', {
@ -221,6 +242,10 @@ $(document).ready(function () {
setup_sports_naming();
});
$('input[name="naming_anime"]').click(function(){
setup_naming();
});
$('#naming_multi_ep').change(fill_examples);
$('#naming_pattern').focusout(fill_examples);
$('#naming_pattern').keyup(function () {

View File

@ -597,13 +597,12 @@ def initialize(consoleLogging=True):
NAMING_PATTERN = check_setting_str(CFG, 'General', 'naming_pattern', 'Season %0S/%SN - S%0SE%0E - %EN')
NAMING_ABD_PATTERN = check_setting_str(CFG, 'General', 'naming_abd_pattern', '%Y/%0M/%SN - %A.D - %EN')
NAMING_CUSTOM_ABD = check_setting_int(CFG, 'General', 'naming_custom_abd', 0)
NAMING_SPORTS_PATTERN = check_setting_str(CFG, 'General', 'naming_sports_pattern',
'Season %0S/%SN - S%0SE%0E - %EN')
NAMING_SPORTS_PATTERN = check_setting_str(CFG, 'General', 'naming_sports_pattern', '%Y/%0M/%SN - %A.D - %EN')
NAMING_ANIME = check_setting_int(CFG, 'General', 'naming_anime', 3)
NAMING_CUSTOM_SPORTS = check_setting_int(CFG, 'General', 'naming_custom_sports', 0)
NAMING_MULTI_EP = check_setting_int(CFG, 'General', 'naming_multi_ep', 1)
NAMING_FORCE_FOLDERS = naming.check_force_season_folders()
NAMING_STRIP_YEAR = bool(check_setting_int(CFG, 'General', 'naming_strip_year', 0))
NAMING_ANIME = check_setting_int(CFG, 'General', 'naming_anime', 3)
USE_NZBS = bool(check_setting_int(CFG, 'General', 'use_nzbs', 0))
USE_TORRENTS = bool(check_setting_int(CFG, 'General', 'use_torrents', 1))

View File

@ -136,11 +136,9 @@ class NameParser(object):
if 'season_num' in named_groups:
tmp_season = int(match.group('season_num'))
if cur_regex_name == 'bare' and tmp_season in (19, 20):
continue
result.season_number = tmp_season
result.score += 1
if not (cur_regex_name == 'bare' and tmp_season in (19, 20)):
result.season_number = tmp_season
result.score += 1
if 'ep_num' in named_groups:
ep_num = self._convert_number(match.group('ep_num'))
@ -198,12 +196,10 @@ class NameParser(object):
tmp_extra_info = match.group('extra_info')
# Show.S04.Special or Show.S05.Part.2.Extras is almost certainly not every episode in the season
if tmp_extra_info and cur_regex_name == 'season_only' and re.search(
r'([. _-]|^)(special|extra)s?\w*([. _-]|$)', tmp_extra_info, re.I):
continue
result.extra_info = tmp_extra_info
result.score += 1
if not (tmp_extra_info and cur_regex_name == 'season_only' and re.search(
r'([. _-]|^)(special|extra)s?\w*([. _-]|$)', tmp_extra_info, re.I)):
result.extra_info = tmp_extra_info
result.score += 1
if 'release_group' in named_groups:
result.release_group = match.group('release_group')
@ -211,6 +207,13 @@ class NameParser(object):
cur_show = helpers.get_show_by_name(result.series_name, useIndexer=self.useIndexers)
if not cur_show:
if self.showObj:
if self.showObj.air_by_date and result.air_date:
result.score += 1
elif self.showObj.sports and result.sports_event_date:
result.score += 1
elif self.showObj.anime and len(result.ab_episode_numbers):
result.score += 1
matches.append(result)
continue

View File

@ -200,6 +200,20 @@ sports_regexs = {'sports':[
-(?P<release_group>[^- ]+))?)?$
'''
),
('sports_bare',
# Sports.Name.2010.11.23.Source.Quality.Etc-Group
# Sports.Name.23rd.Nov.2010.Source.Quality.Etc-Group
'''
^(?P<series_name>.+?)[. _-]+
((?P<sports_event_id>\d{3})[. _-]+)?
((?P<sports_event_name>\.+)[. _-]+)?
(?P<sports_event_date>(\d{4}[. _-]+\d{1,2}[. _-]+\d{1,2})|(\d{1,2}\w{2}[. _-]+\w+[. _-]+\d{4}))
[. _-]*((?P<extra_info>.+?)((?<![. _-])(?<!WEB)
-(?P<release_group>[^- ]+))?)?$
'''
),
]}
anime_regexes = {'anime':[
@ -208,7 +222,7 @@ anime_regexes = {'anime':[
"""
^(?:\[(?P<release_group>.+?)\][ ._-]*)
(?P<series_name>.+?)[ ._-]+
(?P<ep_ab_num>\d{1,3})
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3})
(-(?P<extra_ab_ep_num>\d{1,3}))?[ ._-]+?
(?:v(?P<version>[0-9]))?
(?:[\w\.]*)
@ -227,7 +241,7 @@ anime_regexes = {'anime':[
'''
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
(?P<ep_ab_num>\d{1,3}) # E01
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # E01
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
(v(?P<version>[0-9]))? # version
[ ._-]+\[(?P<extra_info>\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)\] # Source_Quality_Etc-
@ -242,7 +256,7 @@ anime_regexes = {'anime':[
'''
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
(?P<ep_ab_num>\d{1,3}) # E01
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # E01
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
(v(?P<version>[0-9]))? # version
[ ._-]+\((?P<extra_info>(CX[ ._-]?)?\d{3,4}[xp]?\d{0,4}[\.\w\s-]*)\) # Source_Quality_Etc-
@ -255,7 +269,7 @@ anime_regexes = {'anime':[
'''
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
(?P<ep_ab_num>\d{1,3}) # E01
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # E01
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
(v(?P<version>[0-9]))? # version
[ ._-]+\[(?P<extra_info>\d{3,4}p) # Source_Quality_Etc-
@ -271,7 +285,7 @@ anime_regexes = {'anime':[
^(\[(?P<release_group>.+?)\][ ._-]*)? # Release Group and separator
(?P<series_name>.+?)[ ._]* # Show_Name and separator
([ ._-]+-[ ._-]+[A-Z]+[ ._-]+)?[ ._-]+ # funny stuff, this is sooo nuts ! this will kick me in the butt one day
(?P<ep_ab_num>\d{1,3}) # E01
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # E01
(-(?P<extra_ab_ep_num>\d{1,3}))? # E02
(v(?P<version>[0-9]))? # version
([ ._-](\[\w{1,2}\])?\[[a-z][.]?\w{2,4}\])? #codec
@ -301,13 +315,14 @@ anime_regexes = {'anime':[
(([. _-]*e|-) # linking e/- char
(?P<extra_ep_num>\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<ep_ab_num>\d{1,3}) # absolute number
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # absolute number
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
(v(?P<version>[0-9]))? # the version e.g. "v2"
.*?
'''
),
('anime_and_normal_x',
# Bleach - s16e03-04 - 313-314
# Bleach.s16e03-04.313-314
@ -319,7 +334,7 @@ anime_regexes = {'anime':[
(([. _-]*e|-) # linking e/- char
(?P<extra_ep_num>\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<ep_ab_num>\d{1,3}) # absolute number
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # absolute number
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
(v(?P<version>[0-9]))? # the version e.g. "v2"
.*?
@ -331,7 +346,7 @@ anime_regexes = {'anime':[
# Bleach - 313-314 - s16e03-04
'''
^(?P<series_name>.+?)[ ._-]+ # start of string and series name and non optinal separator
(?P<ep_ab_num>\d{1,3}) # absolute number
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # absolute number
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
(v(?P<version>[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
@ -346,7 +361,7 @@ anime_regexes = {'anime':[
('anime_and_normal_front',
# 165.Naruto Shippuuden.s08e014
'''
^(?P<ep_ab_num>\d{1,3}) # start of string and absolute number
^(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # start of string and absolute number
(-(?P<extra_ab_ep_num>\d{1,3}))? # "-" as separator and anditional absolute number, all optinal
(v(?P<version>[0-9]))?[ ._-]+ # the version e.g. "v2"
(?P<series_name>.+?)[ ._-]+
@ -357,18 +372,19 @@ anime_regexes = {'anime':[
.*?
'''
),
('anime_ep_name',
"""
'''
^(?:\[(?P<release_group>.+?)\][ ._-]*)
(?P<series_name>.+?)[ ._-]+
(?P<ep_ab_num>\d{1,3})
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3})
(-(?P<extra_ab_ep_num>\d{1,3}))?[ ._-]*?
(?:v(?P<version>[0-9])[ ._-]+?)?
(?:.+?[ ._-]+?)?
\[(?P<extra_info>\w+)\][ ._-]?
(?:\[(?P<crc>\w{8})\])?
.*?
"""
'''
),
('anime_bare',
@ -377,7 +393,7 @@ anime_regexes = {'anime':[
'''
^(\[(?P<release_group>.+?)\][ ._-]*)?
(?P<series_name>.+?)[ ._-]+ # Show_Name and separator
(?P<ep_ab_num>\d{3}) # E01
(?P<ep_ab_num>(?!(1080|720)[pi])\d{1,3}) # E01
(-(?P<extra_ab_ep_num>\d{3}))? # E02
(v(?P<version>[0-9]))? # v2
.*? # Separator and EOL

View File

@ -40,11 +40,9 @@ name_abd_presets = ('%SN - %A-D - %EN',
'%Y/%0M/%S.N.%A.D.%E.N-%RG'
)
name_sports_presets = ('%SN - %Sx%0E - %EN',
'%S.N.S%0SE%0E.%E.N',
'%Sx%0E - %EN',
'S%0SE%0E - %EN',
'Season %0S/%S.N.S%0SE%0E.%Q.N-%RG'
name_sports_presets = ('%SN - %A-D - %EN',
'%S.N.%A.D.%E.N.%Q.N',
'%Y/%0M/%S.N.%A.D.%E.N-%RG'
)
class TVShow():
@ -98,7 +96,7 @@ class TVEpisode(tv.TVEpisode):
self._is_proper = True
def check_force_season_folders(pattern=None, multi=None):
def check_force_season_folders(pattern=None, multi=None, anime_type=None):
"""
Checks if the name can still be parsed if you strip off the folders to determine if we need to force season folders
to be enabled or not.
@ -108,15 +106,18 @@ def check_force_season_folders(pattern=None, multi=None):
if pattern == None:
pattern = sickbeard.NAMING_PATTERN
valid = not validate_name(pattern, None, file_only=True)
if anime_type == None:
anime_type = sickbeard.NAMING_ANIME
valid = not validate_name(pattern, None, anime_type, file_only=True)
if multi != None:
valid = valid or not validate_name(pattern, multi, file_only=True)
valid = valid or not validate_name(pattern, multi, anime_type, file_only=True)
return valid
def check_valid_naming(pattern=None, multi=None):
def check_valid_naming(pattern=None, multi=None, anime_type=None):
"""
Checks if the name is can be parsed back to its original form for both single and multi episodes.
@ -125,12 +126,15 @@ def check_valid_naming(pattern=None, multi=None):
if pattern == None:
pattern = sickbeard.NAMING_PATTERN
if anime_type == None:
anime_type = sickbeard.NAMING_ANIME
logger.log(u"Checking whether the pattern " + pattern + " is valid for a single episode", logger.DEBUG)
valid = validate_name(pattern, None)
valid = validate_name(pattern, None, anime_type)
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)
valid = valid and validate_name(pattern, multi, anime_type)
return valid
@ -163,10 +167,10 @@ def check_valid_sports_naming(pattern=None):
return valid
def validate_name(pattern, multi=None, file_only=False, abd=False, sports=False):
ep = generate_sample_ep(multi, abd, sports)
def validate_name(pattern, multi=None, anime_type=None, file_only=False, abd=False, sports=False):
ep = generate_sample_ep(multi, abd, sports, anime_type)
new_name = ep.formatted_filename(pattern, multi) + '.ext'
new_name = ep.formatted_filename(pattern, multi, anime_type) + '.ext'
new_path = ep.formatted_dir(pattern, multi)
if not file_only:
new_name = ek.ek(os.path.join, new_path, new_name)
@ -177,7 +181,7 @@ def validate_name(pattern, multi=None, file_only=False, abd=False, sports=False)
logger.log(u"Trying to parse " + new_name, logger.DEBUG)
parser = NameParser(True)
parser = NameParser(True, showObj=ep.show)
try:
result = parser.parse(new_name)
@ -191,18 +195,26 @@ def validate_name(pattern, multi=None, file_only=False, abd=False, sports=False)
if result.air_date != ep.airdate:
logger.log(u"Air date incorrect in parsed episode, pattern isn't valid", logger.DEBUG)
return False
elif sports:
if result.sports_event_date != ep.airdate:
logger.log(u"Sports event date incorrect in parsed episode, pattern isn't valid", logger.DEBUG)
return False
elif anime_type != 3:
if len(result.ab_episode_numbers) and result.ab_episode_numbers != [x.absolute_number for x in [ep] + ep.relatedEps]:
logger.log(u"Absolute numbering 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)
logger.log(u"Season number 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)
logger.log(u"Episode numbering incorrect in parsed episode, pattern isn't valid", logger.DEBUG)
return False
return True
def generate_sample_ep(multi=None, abd=False, sports=False, anime=False):
def generate_sample_ep(multi=None, abd=False, sports=False, anime_type=None):
# make a fake episode object
ep = TVEpisode(2, 3, 3, "Ep Name")
@ -215,31 +227,44 @@ def generate_sample_ep(multi=None, abd=False, sports=False, anime=False):
elif sports:
ep._release_name = 'Show.Name.100.Fighter.vs.Fighter.HDTV.XviD-RLSGROUP'
ep.show.sports = 1
elif anime:
ep._release_name = 'Show.Name.S02E03.HDTV.XviD-RLSGROUP'
ep.show.anime = 1
else:
ep._release_name = 'Show.Name.S02E03.HDTV.XviD-RLSGROUP'
if anime_type != 3:
ep.show.anime = 1
ep._release_name = 'Show.Name.003.HDTV.XviD-RLSGROUP'
else:
ep._release_name = 'Show.Name.S02E03.HDTV.XviD-RLSGROUP'
if multi != None:
ep._name = "Ep Name (1)"
ep._release_name = 'Show.Name.S02E03E04E05.HDTV.XviD-RLSGROUP'
secondEp = TVEpisode(2, 4, 4, "Ep Name (2)")
secondEp._status = Quality.compositeStatus(DOWNLOADED, Quality.HDTV)
secondEp._release_name = ep._release_name
if anime_type != 3:
ep.show.anime = 1
thirdEp = TVEpisode(2, 5, 5, "Ep Name (3)")
thirdEp._status = Quality.compositeStatus(DOWNLOADED, Quality.HDTV)
thirdEp._release_name = ep._release_name
ep._release_name = 'Show.Name.003-004.HDTV.XviD-RLSGROUP'
ep.relatedEps.append(secondEp)
ep.relatedEps.append(thirdEp)
secondEp = TVEpisode(2, 4, 4, "Ep Name (2)")
secondEp._status = Quality.compositeStatus(DOWNLOADED, Quality.HDTV)
secondEp._release_name = ep._release_name
ep.relatedEps.append(secondEp)
else:
ep._release_name = 'Show.Name.S02E03E04E05.HDTV.XviD-RLSGROUP'
secondEp = TVEpisode(2, 4, 4, "Ep Name (2)")
secondEp._status = Quality.compositeStatus(DOWNLOADED, Quality.HDTV)
secondEp._release_name = ep._release_name
thirdEp = TVEpisode(2, 5, 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, sports=False, anime=False):
ep = generate_sample_ep(multi, abd, sports, anime)
def test_name(pattern, multi=None, abd=False, sports=False, anime_type=None):
ep = generate_sample_ep(multi, abd, sports, anime_type)
return {'name': ep.formatted_filename(pattern, multi), 'dir': ep.formatted_dir(pattern, multi)}
return {'name': ep.formatted_filename(pattern, multi, anime_type), 'dir': ep.formatted_dir(pattern, multi)}

View File

@ -2054,7 +2054,7 @@ class TVEpisode(object):
'%XE': str(self.scene_episode),
'%0XE': '%02d' % self.scene_episode,
'%AB': '%(#)03d' % {'#': self.absolute_number},
'%XA': '%(#)03d' % {'#': self.scene_absolute_number},
'%XAB': '%(#)03d' % {'#': self.scene_absolute_number},
'%RN': release_name(self.release_name),
'%RG': release_group(self.release_name),
'%AD': str(self.airdate).replace('-', ' '),
@ -2084,7 +2084,7 @@ class TVEpisode(object):
return result_name
def _format_pattern(self, pattern=None, multi=None):
def _format_pattern(self, pattern=None, multi=None, anime_type=None):
"""
Manipulates an episode naming pattern and then fills the template in
"""
@ -2095,6 +2095,9 @@ class TVEpisode(object):
if multi == None:
multi = sickbeard.NAMING_MULTI_EP
if anime_type == None:
anime_type = sickbeard.NAMING_ANIME
replace_map = self._replace_map()
result_name = pattern
@ -2104,9 +2107,9 @@ class TVEpisode(object):
if self.show.air_by_date or self.show.sports:
result_name = result_name.replace('%RN', '%S.N.%A.D.%E.N-SiCKRAGE')
result_name = result_name.replace('%rn', '%s.n.%A.D.%e.n-sickrage')
elif self.show.is_anime:
result_name = result_name.replace('%RN', '%S.N.%AN.%E.N-SiCKRAGE')
result_name = result_name.replace('%rn', '%s.n.%an.%e.n-sickrage')
elif self.show.anime:
result_name = result_name.replace('%RN', '%S.N.%AB.%E.N-SiCKRAGE')
result_name = result_name.replace('%rn', '%s.n.%ab.%e.n-sickrage')
else:
result_name = result_name.replace('%RN', '%S.N.S%0SE%0E.%E.N-SiCKRAGE')
result_name = result_name.replace('%rn', '%s.n.s%0se%0e.%e.n-sickrage')
@ -2195,16 +2198,39 @@ class TVEpisode(object):
ep_string += other_ep._format_string(ep_format.upper(), other_ep._replace_map())
if season_ep_match:
if self.show.anime and anime_type != 3:
if self.absolute_number == 0:
curAbsolute_number = self.episode
else:
curAbsolute_number = self.absolute_number
if self.season != 0: # dont set absolute numbers if we are on specials !
if anime_type == 1: # this crazy person wants both ! (note: +=)
ep_string += sep + "%(#)03d" % {
"#": curAbsolute_number}
elif anime_type == 2: # total anime freak only need the absolute number ! (note: =)
ep_string = "%(#)03d" % {"#": curAbsolute_number}
for relEp in self.relatedEps:
if relEp.absolute_number != 0:
ep_string += '-' + "%(#)03d" % {"#": relEp.absolute_number}
else:
ep_string += '-' + "%(#)03d" % {"#": relEp.episode}
regex_replacement = None
if anime_type == 2:
regex_replacement = r'\g<pre_sep>' + ep_string + r'\g<post_sep>'
elif season_ep_match:
regex_replacement = r'\g<pre_sep>\g<2>\g<3>' + ep_string + r'\g<post_sep>'
elif ep_only_match:
regex_replacement = ep_string
# 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)
result_name = result_name.replace(cur_name_group, cur_name_group_result)
if regex_replacement:
# 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)
result_name = result_name.replace(cur_name_group, cur_name_group_result)
result_name = self._format_string(result_name, replace_map)
@ -2251,7 +2277,7 @@ class TVEpisode(object):
else:
return self._format_pattern(os.sep.join(name_groups[:-1]), multi)
def formatted_filename(self, pattern=None, multi=None):
def formatted_filename(self, pattern=None, multi=None, anime_type=None):
"""
Just the filename of the episode, formatted based on the naming settings
"""
@ -2268,7 +2294,7 @@ class TVEpisode(object):
# split off the dirs only, if they exist
name_groups = re.split(r'[\\/]', pattern)
return self._format_pattern(name_groups[-1], multi)
return self._format_pattern(name_groups[-1], multi, anime_type)
def rename(self):
"""

View File

@ -1267,7 +1267,6 @@ class ConfigPostProcessing:
sickbeard.NAMING_CUSTOM_ABD = config.checkbox_to_value(naming_custom_abd)
sickbeard.NAMING_CUSTOM_SPORTS = config.checkbox_to_value(naming_custom_sports)
sickbeard.NAMING_STRIP_YEAR = config.checkbox_to_value(naming_strip_year)
sickbeard.NAMING_ANIME = config.checkbox_to_value(naming_anime)
sickbeard.USE_FAILED_DOWNLOADS = config.checkbox_to_value(use_failed_downloads)
sickbeard.DELETE_FAILED = config.checkbox_to_value(delete_failed)
sickbeard.SKIP_REMOVED_FILES = config.checkbox_to_value(skip_removed_files)
@ -1288,12 +1287,16 @@ class ConfigPostProcessing:
sickbeard.metadata_provider_dict['TIVO'].set_config(sickbeard.METADATA_TIVO)
sickbeard.metadata_provider_dict['Mede8er'].set_config(sickbeard.METADATA_MEDE8ER)
if self.isNamingValid(naming_pattern, naming_multi_ep) != "invalid":
if self.isNamingValid(naming_pattern, naming_multi_ep, anime_type=naming_anime) != "invalid":
sickbeard.NAMING_PATTERN = naming_pattern
sickbeard.NAMING_MULTI_EP = int(naming_multi_ep)
sickbeard.NAMING_ANIME = int(naming_anime)
sickbeard.NAMING_FORCE_FOLDERS = naming.check_force_season_folders()
else:
results.append("You tried saving an invalid naming config, not saving your naming settings")
if int(naming_anime) in [1, 2]:
results.append("You tried saving an invalid anime naming config, not saving your naming settings")
else:
results.append("You tried saving an invalid naming config, not saving your naming settings")
if self.isNamingValid(naming_abd_pattern, None, abd=True) != "invalid":
sickbeard.NAMING_ABD_PATTERN = naming_abd_pattern
@ -1320,22 +1323,31 @@ class ConfigPostProcessing:
redirect("/config/postProcessing/")
@cherrypy.expose
def testNaming(self, pattern=None, multi=None, abd=False, sports=False, anime=None):
def testNaming(self, pattern=None, multi=None, abd=False, sports=False, anime_type=None):
if multi is not None:
multi = int(multi)
result = naming.test_name(pattern, multi, abd, sports, anime)
if anime_type is not None:
anime_type = int(anime_type)
result = naming.test_name(pattern, multi, abd, sports, anime_type)
result = ek.ek(os.path.join, result['dir'], result['name'])
return result
@cherrypy.expose
def isNamingValid(self, pattern=None, multi=None, abd=False, sports=False):
def isNamingValid(self, pattern=None, multi=None, abd=False, sports=False, anime_type=None):
if pattern is None:
return "invalid"
if multi is not None:
multi = int(multi)
if anime_type is not None:
anime_type = int(anime_type)
# air by date shows just need one check, we don't need to worry about season folders
if abd:
is_valid = naming.check_valid_abd_naming(pattern)
@ -1348,10 +1360,10 @@ class ConfigPostProcessing:
else:
# check validity of single and multi ep cases for the whole path
is_valid = naming.check_valid_naming(pattern, multi)
is_valid = naming.check_valid_naming(pattern, multi, anime_type)
# check validity of single and multi ep cases for only the file name
require_season_folders = naming.check_force_season_folders(pattern, multi)
require_season_folders = naming.check_force_season_folders(pattern, multi, anime_type)
if is_valid and not require_season_folders:
return "valid"