Settings
Movie List Directory selection
This commit is contained in:
1 parent
272e0b8527
commit
8682be33fb
27 files changed
+1770
-233
No files matched your search
@@ -1,12 +1,59 @@
|
||||
from uuid import uuid4
|
||||
|
||||
config = ('global', {
|
||||
'debug': False,
|
||||
'host': '0.0.0.0',
|
||||
'port': 5000,
|
||||
'username': '',
|
||||
'password': '',
|
||||
'launch_browser': True,
|
||||
'url_base': '',
|
||||
'api_key': uuid4().hex,
|
||||
})
|
||||
config = [{
|
||||
'name': 'global',
|
||||
'tab': 'general',
|
||||
'options': {
|
||||
'debug': {
|
||||
'advanced': True,
|
||||
'default': False,
|
||||
'type': 'bool',
|
||||
'label': 'Debug',
|
||||
'description': 'Enable debugging.',
|
||||
},
|
||||
'host': {
|
||||
'advanced': True,
|
||||
'default': '0.0.0.0',
|
||||
'type': 'string',
|
||||
'label': 'Host',
|
||||
'description': 'Host that I should listen to 0.0.0.0 listens to everything.',
|
||||
},
|
||||
'port': {
|
||||
'default': 5000,
|
||||
'type': 'int',
|
||||
'label': 'Port',
|
||||
'description': 'The port I should listen to.',
|
||||
},
|
||||
'username': {
|
||||
'default': '',
|
||||
'type': 'string',
|
||||
'label': 'Username',
|
||||
},
|
||||
'password': {
|
||||
'default': '',
|
||||
'password': True,
|
||||
'type': 'string',
|
||||
'label': 'Password',
|
||||
},
|
||||
'launch_browser': {
|
||||
'default': True,
|
||||
'type': 'bool',
|
||||
'label': 'Launch Browser',
|
||||
'description': 'Launch the browser when I start.',
|
||||
},
|
||||
'url_base': {
|
||||
'advanced': True,
|
||||
'default': '',
|
||||
'type': 'string',
|
||||
'label': 'Url Base',
|
||||
'description': 'When using mod_proxy use this to prepend the url with this.',
|
||||
},
|
||||
'api_key': {
|
||||
'default': uuid4().hex,
|
||||
'type': 'string',
|
||||
'readonly': True,
|
||||
'label': 'Api Key',
|
||||
'description': 'This is top-secret! Don\'t share this!',
|
||||
}
|
||||
}
|
||||
}]
|
||||
@@ -1,4 +1,30 @@
|
||||
config = ('Renamer', {
|
||||
'enabled': False,
|
||||
'cleanup': False
|
||||
})
|
||||
config = [{
|
||||
'name': 'Renamer',
|
||||
'tab': 'renaming',
|
||||
'options': {
|
||||
'enabled': {
|
||||
'default': False,
|
||||
'type': 'bool',
|
||||
'description': 'Enable renaming',
|
||||
},
|
||||
'from': {
|
||||
'default': '',
|
||||
'type': 'directory',
|
||||
'label': 'From',
|
||||
'description': 'Folder where the movies are downloaded to.',
|
||||
},
|
||||
'to': {
|
||||
'default': '',
|
||||
'type': 'directory',
|
||||
'label': 'To',
|
||||
'description': 'Folder where the movies will be moved to.',
|
||||
},
|
||||
'run_every': {
|
||||
'default': 1,
|
||||
'type': 'int',
|
||||
'unit': 'min(s)',
|
||||
'description': 'Search for new movies inside the folder every X minutes.',
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
config = ('TheMovieDB', {
|
||||
'key': '9b939aee0aaafc12a65bf448e4af9543'
|
||||
})
|
||||
config = [{
|
||||
'name': 'TheMovieDB',
|
||||
'tab': 'providers',
|
||||
'options': {
|
||||
'api_key': {
|
||||
'advanced': True,
|
||||
'default': '9b939aee0aaafc12a65bf448e4af9543',
|
||||
'type': 'string',
|
||||
'description': 'Api key to use for calls to TheMovieDB.',
|
||||
}
|
||||
}
|
||||
}]
|
||||
@@ -27,7 +27,7 @@ class Settings():
|
||||
return self.p
|
||||
|
||||
def sections(self):
|
||||
return self.s
|
||||
return self.p.sections()
|
||||
|
||||
def connectSignals(self):
|
||||
signal('settings.register').connect(self.registerDefaults)
|
||||
@@ -46,24 +46,34 @@ class Settings():
|
||||
self.save(self)
|
||||
|
||||
def set(self, section, option, value):
|
||||
return self.p.set(section, option, value)
|
||||
return self.p.set(section, option, self.cleanValue(value))
|
||||
|
||||
def get(self, option = '', section = 'global', default = ''):
|
||||
|
||||
try:
|
||||
value = self.p.get(section, option)
|
||||
|
||||
if(self.is_int(value)):
|
||||
return int(value)
|
||||
|
||||
if str(value).lower() in self.bool:
|
||||
return self.bool.get(str(value).lower())
|
||||
|
||||
return value if type(value) != str else value.strip()
|
||||
return self.cleanValue(value)
|
||||
except:
|
||||
return default
|
||||
|
||||
def save(self, caller):
|
||||
def cleanValue(self, value):
|
||||
if(self.is_int(value)):
|
||||
return int(value)
|
||||
|
||||
if str(value).lower() in self.bool:
|
||||
return self.bool.get(str(value).lower())
|
||||
|
||||
return value.strip()
|
||||
|
||||
def getValues(self):
|
||||
values = {}
|
||||
for section in self.sections():
|
||||
values[section] = {}
|
||||
for option in self.p.items(section):
|
||||
(option_name, option_value) = option
|
||||
values[section][option_name] = option_value
|
||||
return values
|
||||
|
||||
def save(self, caller = ''):
|
||||
with open(self.file, 'wb') as configfile:
|
||||
self.p.write(configfile)
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@ log = CPLog(__name__)
|
||||
class SettingsLoader:
|
||||
|
||||
configs = {}
|
||||
sections = {}
|
||||
|
||||
def __init__(self, root = ''):
|
||||
|
||||
def __init__(self):
|
||||
self.settings_register = signal('settings.register')
|
||||
self.settings_save = signal('settings.save')
|
||||
|
||||
def load(self, root = ''):
|
||||
|
||||
self.paths = {
|
||||
'plugins' : ('couchpotato.core.plugins', os.path.join(root, 'couchpotato', 'core', 'plugins')),
|
||||
'providers' : ('couchpotato.core.providers', os.path.join(root, 'couchpotato', 'core', 'providers')),
|
||||
@@ -42,8 +44,13 @@ class SettingsLoader:
|
||||
module_name = '%s.%s' % (module, name)
|
||||
try:
|
||||
m = getattr(self.loadModule(module_name), name)
|
||||
(section, options) = m.config
|
||||
self.settings_register.send(section, options = options, save = save)
|
||||
|
||||
for section in m.config:
|
||||
self.addSection(section['name'], section)
|
||||
options = {}
|
||||
for key, option in section['options'].iteritems():
|
||||
options[key] = option['default']
|
||||
self.settings_register.send(section['name'], options = options, save = save)
|
||||
|
||||
return True
|
||||
except Exception, e:
|
||||
@@ -62,3 +69,11 @@ class SettingsLoader:
|
||||
return m
|
||||
except:
|
||||
raise
|
||||
|
||||
def addSection(self, section_name, options):
|
||||
self.sections[section_name] = options
|
||||
|
||||
def getSections(self):
|
||||
return self.sections
|
||||
|
||||
settings_loader = SettingsLoader()
|
||||
Reference in new issue
Block a user