2018-10-03 18:34:45 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""Top-level package for mopidy-funkwhale."""
|
2018-10-03 18:58:50 +02:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import mopidy.config
|
|
|
|
import mopidy.ext
|
|
|
|
import os
|
|
|
|
|
2018-10-03 18:34:45 +02:00
|
|
|
|
|
|
|
__author__ = """Eliot Berriot"""
|
|
|
|
__email__ = 'contact+funkwhale@eliotberriot.com'
|
|
|
|
__version__ = '0.1.0'
|
2018-10-03 18:58:50 +02:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Extension(mopidy.ext.Extension):
|
|
|
|
|
|
|
|
dist_name = 'Mopidy-Funkwhale'
|
|
|
|
ext_name = 'funkwhale'
|
|
|
|
version = __version__
|
|
|
|
|
|
|
|
def get_default_config(self):
|
|
|
|
conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf')
|
|
|
|
return mopidy.config.read(conf_file)
|
|
|
|
|
|
|
|
def get_config_schema(self):
|
|
|
|
schema = super(Extension, self).get_config_schema()
|
|
|
|
schema['url'] = mopidy.config.String()
|
2018-10-03 21:51:48 +02:00
|
|
|
schema['username'] = mopidy.config.String(optional=True)
|
2018-10-03 18:58:50 +02:00
|
|
|
schema['password'] = mopidy.config.Secret(optional=True)
|
|
|
|
return schema
|
|
|
|
|
2018-10-03 21:51:48 +02:00
|
|
|
def validate_config(self, config):
|
|
|
|
if not config.getboolean('funkwhale', 'enabled'):
|
|
|
|
return
|
|
|
|
username = config.getstring('funkwhale', 'username')
|
|
|
|
password = config.getstring('funkwhale', 'password')
|
|
|
|
if any([username, password]) and not all([username, password]):
|
|
|
|
raise mopidy.ext.ExtensionError(
|
|
|
|
'You need to provide username and password to authenticate with the funkwhale backend'
|
|
|
|
)
|
|
|
|
|
2018-10-03 18:58:50 +02:00
|
|
|
def setup(self, registry):
|
2018-10-03 21:51:48 +02:00
|
|
|
from . import actor
|
|
|
|
registry.add('backend', actor.FunkwhaleBackend)
|