|
@ -175,6 +175,9 @@ class OptionsManager(object): |
|
|
the LogManager. See main() function under __init__(). |
|
|
the LogManager. See main() function under __init__(). |
|
|
|
|
|
|
|
|
log_time (boolean): See logmanager.LogManager add_time attribute. |
|
|
log_time (boolean): See logmanager.LogManager add_time attribute. |
|
|
|
|
|
|
|
|
|
|
|
workers_number (int): Number of download workers that download manager |
|
|
|
|
|
will spawn. Must be greater than zero. |
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
self.options = { |
|
|
self.options = { |
|
@ -217,7 +220,8 @@ class OptionsManager(object): |
|
|
'youtubedl_path': self.config_path, |
|
|
'youtubedl_path': self.config_path, |
|
|
'cmd_args': '', |
|
|
'cmd_args': '', |
|
|
'enable_log': True, |
|
|
'enable_log': True, |
|
|
'log_time': False |
|
|
|
|
|
|
|
|
'log_time': False, |
|
|
|
|
|
'workers_number': 3 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
def load_from_file(self): |
|
|
def load_from_file(self): |
|
@ -228,12 +232,12 @@ class OptionsManager(object): |
|
|
with open(self.settings_file, 'rb') as settings_file: |
|
|
with open(self.settings_file, 'rb') as settings_file: |
|
|
try: |
|
|
try: |
|
|
options = json.load(settings_file) |
|
|
options = json.load(settings_file) |
|
|
|
|
|
|
|
|
|
|
|
if self._settings_are_valid(options): |
|
|
|
|
|
self.options = options |
|
|
except: |
|
|
except: |
|
|
self.load_default() |
|
|
self.load_default() |
|
|
|
|
|
|
|
|
if self._settings_are_valid(options): |
|
|
|
|
|
self.options = options |
|
|
|
|
|
|
|
|
|
|
|
def save_to_file(self): |
|
|
def save_to_file(self): |
|
|
"""Save options to settings file. """ |
|
|
"""Save options to settings file. """ |
|
|
check_path(self.config_path) |
|
|
check_path(self.config_path) |
|
@ -290,6 +294,11 @@ class OptionsManager(object): |
|
|
for key, valid_list in rules_dict.items(): |
|
|
for key, valid_list in rules_dict.items(): |
|
|
if settings_dictionary[key] not in valid_list: |
|
|
if settings_dictionary[key] not in valid_list: |
|
|
return False |
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
settings_dictionary['workers_number'] = int(settings_dictionary['workers_number']) |
|
|
|
|
|
|
|
|
|
|
|
if settings_dictionary['workers_number'] < 1: |
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|