lastfm: Add default config and config schema
This commit is contained in:
parent
aab7c01c94
commit
7ea233b7f9
@ -1,10 +1,23 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import mopidy
|
import mopidy
|
||||||
from mopidy import ext
|
from mopidy import exceptions, ext
|
||||||
from mopidy.exceptions import ExtensionError
|
from mopidy.utils import config, formatting
|
||||||
|
|
||||||
|
|
||||||
|
default_config = """
|
||||||
|
[ext.lastfm]
|
||||||
|
|
||||||
|
# If the Last.fm extension should be enabled or not
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
# Your Last.fm username
|
||||||
|
username =
|
||||||
|
|
||||||
|
# Your Last.fm password
|
||||||
|
password =
|
||||||
|
"""
|
||||||
|
|
||||||
__doc__ = """
|
__doc__ = """
|
||||||
Frontend which scrobbles the music you play to your `Last.fm
|
Frontend which scrobbles the music you play to your `Last.fm
|
||||||
<http://www.last.fm>`_ profile.
|
<http://www.last.fm>`_ profile.
|
||||||
@ -17,15 +30,16 @@ Frontend which scrobbles the music you play to your `Last.fm
|
|||||||
|
|
||||||
.. literalinclude:: ../../../requirements/lastfm.txt
|
.. literalinclude:: ../../../requirements/lastfm.txt
|
||||||
|
|
||||||
**Settings:**
|
**Default config:**
|
||||||
|
|
||||||
- :attr:`mopidy.settings.LASTFM_USERNAME`
|
.. code-block:: ini
|
||||||
- :attr:`mopidy.settings.LASTFM_PASSWORD`
|
|
||||||
|
%(config)s
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
|
|
||||||
The frontend is enabled by default if all dependencies are available.
|
The frontend is enabled by default if all dependencies are available.
|
||||||
"""
|
""" % {'config': formatting.indent(default_config)}
|
||||||
|
|
||||||
|
|
||||||
class Extension(ext.Extension):
|
class Extension(ext.Extension):
|
||||||
@ -34,16 +48,19 @@ class Extension(ext.Extension):
|
|||||||
version = mopidy.__version__
|
version = mopidy.__version__
|
||||||
|
|
||||||
def get_default_config(self):
|
def get_default_config(self):
|
||||||
return '[ext.lastfm]'
|
return default_config
|
||||||
|
|
||||||
def validate_config(self, config):
|
def get_config_schema(self):
|
||||||
pass
|
schema = config.ExtensionConfigSchema()
|
||||||
|
schema['username'] = config.String()
|
||||||
|
schema['password'] = config.String(secret=True)
|
||||||
|
return schema
|
||||||
|
|
||||||
def validate_environment(self):
|
def validate_environment(self):
|
||||||
try:
|
try:
|
||||||
import pylast # noqa
|
import pylast # noqa
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ExtensionError('pylast library not found', e)
|
raise exceptions.ExtensionError('pylast library not found', e)
|
||||||
|
|
||||||
def get_frontend_classes(self):
|
def get_frontend_classes(self):
|
||||||
from .actor import LastfmFrontend
|
from .actor import LastfmFrontend
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user