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"""
|
2018-10-04 20:57:27 +02:00
|
|
|
__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):
|
|
|
|
|
2018-10-04 20:57:27 +02:00
|
|
|
dist_name = "Mopidy-Funkwhale"
|
|
|
|
ext_name = "funkwhale"
|
2018-10-03 18:58:50 +02:00
|
|
|
version = __version__
|
|
|
|
|
|
|
|
def get_default_config(self):
|
2018-10-04 20:57:27 +02:00
|
|
|
conf_file = os.path.join(os.path.dirname(__file__), "ext.conf")
|
2018-10-03 18:58:50 +02:00
|
|
|
return mopidy.config.read(conf_file)
|
|
|
|
|
|
|
|
def get_config_schema(self):
|
|
|
|
schema = super(Extension, self).get_config_schema()
|
2018-10-04 20:57:27 +02:00
|
|
|
schema["url"] = mopidy.config.String()
|
2019-05-03 12:22:45 +02:00
|
|
|
schema["authorization_endpoint"] = mopidy.config.String(optional=True)
|
|
|
|
schema["token_endpoint"] = mopidy.config.String(optional=True)
|
|
|
|
schema["client_secret"] = mopidy.config.String(optional=True)
|
|
|
|
schema["client_id"] = mopidy.config.String(optional=True)
|
|
|
|
|
2018-10-04 20:57:27 +02:00
|
|
|
schema["username"] = mopidy.config.String(optional=True)
|
|
|
|
schema["password"] = mopidy.config.Secret(optional=True)
|
2018-10-05 00:06:09 +02:00
|
|
|
schema["cache_duration"] = mopidy.config.Integer(optional=True)
|
2019-05-03 12:22:45 +02:00
|
|
|
schema["verify_cert"] = mopidy.config.Boolean(optional=True)
|
2021-08-17 04:15:24 +02:00
|
|
|
|
|
|
|
schema["show_track_artists"] = mopidy.config.Boolean(optional=True)
|
|
|
|
|
2018-10-03 18:58:50 +02:00
|
|
|
return schema
|
|
|
|
|
2018-10-03 21:51:48 +02:00
|
|
|
def validate_config(self, config):
|
2018-10-04 20:57:27 +02:00
|
|
|
if not config.getboolean("funkwhale", "enabled"):
|
2018-10-03 21:51:48 +02:00
|
|
|
return
|
2018-10-04 20:57:27 +02:00
|
|
|
username = config.getstring("funkwhale", "username")
|
|
|
|
password = config.getstring("funkwhale", "password")
|
2018-10-03 21:51:48 +02:00
|
|
|
if any([username, password]) and not all([username, password]):
|
|
|
|
raise mopidy.ext.ExtensionError(
|
2018-10-04 20:57:27 +02:00
|
|
|
"You need to provide username and password to authenticate with the funkwhale backend"
|
2018-10-03 21:51:48 +02:00
|
|
|
)
|
|
|
|
|
2018-10-03 18:58:50 +02:00
|
|
|
def setup(self, registry):
|
2018-10-03 21:51:48 +02:00
|
|
|
from . import actor
|
2018-10-04 20:57:27 +02:00
|
|
|
|
|
|
|
registry.add("backend", actor.FunkwhaleBackend)
|
2019-05-03 12:22:45 +02:00
|
|
|
|
|
|
|
def get_command(self):
|
|
|
|
from . import commands
|
|
|
|
|
|
|
|
return commands.FunkwhaleCommand()
|