Extension API¶
If you want to learn how to make Mopidy extensions, read Extension development.
-
class
mopidy.ext.Extension[source]¶ Base class for Mopidy extensions
-
dist_name= None¶ The extension’s distribution name, as registered on PyPI
Example:
Mopidy-Soundspot
-
ext_name= None¶ The extension’s short name, as used in setup.py and as config section name
Example:
soundspot
-
get_backend_classes()[source]¶ List of backend actor classes
Deprecated since version 0.18: Use
setup()instead.Returns: list of Backendsubclasses
-
get_command()[source]¶ Command to expose to command line users running mopidy.
Returns: Instance of a Commandclass.
-
get_default_config()[source]¶ The extension’s default config as a bytestring
Returns: bytes or unicode
-
get_frontend_classes()[source]¶ List of frontend actor classes
Deprecated since version 0.18: Use
setup()instead.Returns: list of pykka.Actorsubclasses
-
register_gstreamer_elements()[source]¶ Hook for registering custom GStreamer elements.
Deprecated since version 0.18: Use
setup()instead.Returns: None
-
setup(registry)[source]¶ Register the extension’s components in the extension
Registry.For example, to register a backend:
def setup(self, registry): from .backend import SoundspotBackend registry.add('backend', SoundspotBackend)
See
Registryfor a list of registry keys with a special meaning. Mopidy will instantiate and start any classes registered under thefrontendandbackendregistry keys.This method can also be used for other setup tasks not involving the extension registry. For example, to register custom GStreamer elements:
def setup(self, registry): from .mixer import SoundspotMixer gobject.type_register(SoundspotMixer) gst.element_register( SoundspotMixer, 'soundspotmixer', gst.RANK_MARGINAL)
Parameters: registry ( Registry) – the extension registry
-
validate_environment()[source]¶ Checks if the extension can run in the current environment
For example, this method can be used to check if all dependencies that are needed are installed. If a problem is found, raise
ExtensionErrorwith a message explaining the issue.Raises: ExtensionErrorReturns: None
-
version= None¶ The extension’s version
Should match the
__version__attribute on the extension’s main Python module and the version registered on PyPI.
-
-
class
mopidy.ext.Registry[source]¶ Registry of components provided by Mopidy extensions.
Passed to the
setup()method of all extensions. The registry can be used like a dict of string keys and lists.Some keys have a special meaning, including, but not limited to:
backendis used for Mopidy backend classes.frontendis used for Mopidy frontend classes.local:libraryis used for Mopidy-Local libraries.
Extensions can use the registry for allow other to extend the extension itself. For example the
Mopidy-Localuse thelocal:librarykey to allow other extensions to register library providers forMopidy-Localto use. Extensions should namespace custom keys with the extension’sext_name, e.g.local:fooorhttp:bar.