spotify: Add config schema
This commit is contained in:
parent
aba8329660
commit
d6d3e2be35
@ -3,10 +3,10 @@ from __future__ import unicode_literals
|
|||||||
import mopidy
|
import mopidy
|
||||||
from mopidy import ext
|
from mopidy import ext
|
||||||
from mopidy.exceptions import ExtensionError
|
from mopidy.exceptions import ExtensionError
|
||||||
from mopidy.utils.formatting import indent
|
from mopidy.utils import config, formatting
|
||||||
|
|
||||||
|
|
||||||
config = """
|
default_config = """
|
||||||
[ext.spotify]
|
[ext.spotify]
|
||||||
|
|
||||||
# If the Spotify extension should be enabled or not
|
# If the Spotify extension should be enabled or not
|
||||||
@ -62,7 +62,7 @@ https://github.com/mopidy/mopidy/issues?labels=Spotify+backend
|
|||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
|
|
||||||
%(config)s
|
%(config)s
|
||||||
""" % {'config': indent(config)}
|
""" % {'config': formatting.indent(default_config)}
|
||||||
|
|
||||||
|
|
||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
@ -71,15 +71,19 @@ class Extension(ext.Extension):
|
|||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
return config
|
return default_config
|
||||||
|
|
||||||
def validate_config(self, config):
|
def get_config_schema(self):
|
||||||
if not config.getboolean('spotify', 'enabled'):
|
schema = config.ExtensionConfigSchema()
|
||||||
return
|
schema['username'] = config.String()
|
||||||
if not config.get('spotify', 'username'):
|
schema['password'] = config.String(secret=True)
|
||||||
raise ExtensionError('Config spotify.username not set')
|
schema['bitrate'] = config.Integer(choices=(96, 160, 320))
|
||||||
if not config.get('spotify', 'password'):
|
schema['timeout'] = config.Integer(minimum=0)
|
||||||
raise ExtensionError('Config spotify.password not set')
|
schema['cache_path'] = config.String()
|
||||||
|
schema['proxy_host'] = config.Hostname(optional=True)
|
||||||
|
schema['proxy_username'] = config.String(optional=True)
|
||||||
|
schema['proxy_password'] = config.String(optional=True, secret=True)
|
||||||
|
return schema
|
||||||
|
|
||||||
def validate_environment(self):
|
def validate_environment(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user