Add Enable chmod setting

pull/388/head
Halali 6 years ago
parent b616ec76e0
commit a1a1ee68f1

@ -35,6 +35,7 @@ defaults = {
'enabled_providers': '', 'enabled_providers': '',
'throtteled_providers': '{}', 'throtteled_providers': '{}',
'multithreading': 'True', 'multithreading': 'True',
'chmod_enabled': 'False',
'chmod': '0640', 'chmod': '0640',
'subfolder': 'current', 'subfolder': 'current',
'subfolder_custom': '', 'subfolder_custom': '',

@ -170,7 +170,7 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
try: try:
fld = get_target_folder(path) fld = get_target_folder(path)
chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') else None chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') and settings.general.getboolean('chmod_enabled') else None
saved_subtitles = save_subtitles(video.original_path, subtitles, single=single, saved_subtitles = save_subtitles(video.original_path, subtitles, single=single,
tags=None, # fixme tags=None, # fixme
directory=fld, directory=fld,
@ -361,7 +361,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
try: try:
score = round(subtitle.score / max_score * 100, 2) score = round(subtitle.score / max_score * 100, 2)
fld = get_target_folder(path) fld = get_target_folder(path)
chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') else None chmod = int(settings.general.chmod, 8) if not sys.platform.startswith('win') and settings.general.getboolean('chmod_enabled') else None
saved_subtitles = save_subtitles(video.original_path, [subtitle], single=single, saved_subtitles = save_subtitles(video.original_path, [subtitle], single=single,
tags=None, # fixme tags=None, # fixme
directory=fld, directory=fld,

@ -1197,6 +1197,11 @@ def save_settings():
settings_general_debug = 'False' settings_general_debug = 'False'
else: else:
settings_general_debug = 'True' settings_general_debug = 'True'
settings_general_chmod_enabled = request.forms.get('settings_general_chmod_enabled')
if settings_general_chmod_enabled is None:
settings_general_chmod_enabled = 'False'
else:
settings_general_chmod_enabled = 'True'
settings_general_chmod = request.forms.get('settings_general_chmod') settings_general_chmod = request.forms.get('settings_general_chmod')
settings_general_sourcepath = request.forms.getall('settings_general_sourcepath') settings_general_sourcepath = request.forms.getall('settings_general_sourcepath')
settings_general_destpath = request.forms.getall('settings_general_destpath') settings_general_destpath = request.forms.getall('settings_general_destpath')
@ -1283,6 +1288,7 @@ def save_settings():
settings.general.base_url = text_type(settings_general_baseurl) settings.general.base_url = text_type(settings_general_baseurl)
settings.general.path_mappings = text_type(settings_general_pathmapping) settings.general.path_mappings = text_type(settings_general_pathmapping)
settings.general.debug = text_type(settings_general_debug) settings.general.debug = text_type(settings_general_debug)
settings.general.chmod_enabled = text_type(settings_general_chmod_enabled)
settings.general.chmod = text_type(settings_general_chmod) settings.general.chmod = text_type(settings_general_chmod)
settings.general.branch = text_type(settings_general_branch) settings.general.branch = text_type(settings_general_branch)
settings.general.auto_update = text_type(settings_general_automatic) settings.general.auto_update = text_type(settings_general_automatic)

@ -152,6 +152,17 @@
</div> </div>
</div> </div>
</div> </div>
<div id="chmod_enabled" class="middle aligned row">
<div class="right aligned four wide column">
<label>Enable chmod</label>
</div>
<div class="five wide column">
<div id="settings_chmod_enabled" class="ui toggle checkbox" data-chmod={{settings.general.getboolean('chmod_enabled')}}>
<input name="settings_general_chmod_enabled" type="checkbox">
<label></label>
</div>
</div>
</div>
<div id="chmod" class="middle aligned row"> <div id="chmod" class="middle aligned row">
<div class="right aligned four wide column"> <div class="right aligned four wide column">
<label>Set subtitle file permissions to</label> <label>Set subtitle file permissions to</label>
@ -599,7 +610,7 @@
</div> </div>
</div> </div>
<div class="middle aligned row"> <div class="middle aligned row postprocessing">
<div class="right aligned four wide column"> <div class="right aligned four wide column">
<label>Post-processing command</label> <label>Post-processing command</label>
</div> </div>
@ -610,7 +621,7 @@
</div> </div>
</div> </div>
<div class="middle aligned row"> <div class="middle aligned row postprocessing">
<div class="right aligned four wide column"> <div class="right aligned four wide column">
<label>Variables you can use in your command (include the double curly brace):</label> <label>Variables you can use in your command (include the double curly brace):</label>
</div> </div>
@ -2032,6 +2043,7 @@
% import sys % import sys
% if sys.platform.startswith('win'): % if sys.platform.startswith('win'):
$("#chmod").hide(); $("#chmod").hide();
$("#chmod_enabled").hide();
% end % end
$('.menu .item') $('.menu .item')
@ -2070,6 +2082,12 @@
$("#settings_debug").checkbox('uncheck'); $("#settings_debug").checkbox('uncheck');
} }
if ($('#settings_chmod_enabled').data("chmod") === "True") {
$("#settings_chmod_enabled").checkbox('check');
} else {
$("#settings_chmod_enabled").checkbox('uncheck');
}
if ($('#settings_single_language').data("single-language") === "True") { if ($('#settings_single_language').data("single-language") === "True") {
$("#settings_single_language").checkbox('check'); $("#settings_single_language").checkbox('check');
} else { } else {
@ -2247,6 +2265,21 @@
} }
}); });
if ($('#settings_chmod_enabled').data("chmod") === "True") {
$('#chmod').show();
} else {
$('#chmod').hide();
}
$('#settings_chmod_enabled').checkbox({
onChecked: function() {
$('#chmod').show();
},
onUnchecked: function() {
$('#chmod').hide();
}
});
if ($('#settings_auth_type').val() === "None") { if ($('#settings_auth_type').val() === "None") {
$('.auth_option').hide(); $('.auth_option').hide();
} }
@ -2467,7 +2500,7 @@
} }
] ]
}, },
% if not sys.platform.startswith('win'): % if not sys.platform.startswith('win') and settings.general.getboolean('chmod_enabled'):
settings_general_chmod: { settings_general_chmod: {
rules: [ rules: [
{ {

Loading…
Cancel
Save