Skip to main content

mopidris

MPRIS2 D-Bus for a (remote) Mopidy instance.

Background

Many desktop environments can control a media player through the D-Bus via the Media Player Remote Interfacing Specification (MPRIS) interface. To control a locally running instance of Mopidy, there exists the Mopidy-MPRIS package:

For this to work, Mopidy has to run on the same computer as the the D-Bus. If Mopidy runs on a remote server, up to now there was only the following solution available:

  1. Install and enable the MPD interface for Mopidy:
  2. Install mpDris2.
  3. Start mpDris2, whenever you log into your desktop environment.

The mopidris introduced here, connects directly to a local or remote Mopidy without the detour through the mpd interface.

There is an additional (and probably controversial) feature implemented: Internet radio streams do often send artist and title as one metatag. If those two fields are separated by " - ", it is split and presented as artist and title to the D-Bus. (This is the default behaviour and can be switched off with the --no-mangle command line parameter.)

Installation

pip install mopidris

This installs these additional packages:

Optional packages

You can install the following optional packages. mopidris makes use of them, if it can find them, but it also works well without them:

  1. aiorun: If the event loop is terminated with CTRL-C, sometimes the port is not released and 'mopidris' cannot be restarted. 'aiorun' can help here (but it can still happen, that the DBUS hangs ...)
  2. colored_traceback: Shows coloured tracebacks, to help debugging exceptions.
  3. colorlog: Colour the log to make it easier to read.

Usage

Command line

The program is started with

python3 /path/to/mopidris

e.g. if mopidris is installed into the directory /usr/local/lib/python3.8/dist-packages/mopidris/, call it with

python3 /usr/local/lib/python3.8/dist-packages/mopidris

The most important options are undeniably the (optional) positional parameter specifying the host and possibly --retries and --can-quit. For the full list, see the section "Command line options" near the end.

Configuration file

Instead of giving the parameters all the time when calling mopidris, it is possible to write them into a configuration file. The default location can be found by calling python3 mopidris --help (look for the --config option).

A possible configuration file can look like this:

# Remote host ip
host = 192.168.0.1

# Retry forever
reconnect_attempts = -1

# Wait 60s between retries
reconnect_timeout = 60

.desktop file

If this mopidy.desktop is installed (e.g. into /usr/local/share/applications or to ${HOME}/.local/share/applications, it is probably possible to start mopidris on a Linux system from the sound applet. For this to work, the file has to be named mopidris.desktop and the program at least started once manually!

Do not forget to update the path in the file to your installation directory!

Start automatically

There exists two possible ways to start mopidris automatically, whenever a user logs in:

Startup Applications

Put python3 /path/to/mopidris with the required command line options (or a configuration file) into your Startup Applications.

If you have installed the mopidy.desktop file as described above, this file can be used in the Startup Applications.

systemd service

NB: This is not tested, so please feel free to open an issue and post a correction to the procedure!

It is also possible to start it via a systemd service.

Copy the mopidris.service file to /usr/lib/systemd/user (or the user's equivalent) and activate it with:

systemctl --user enable mopidris.service
systemctl --user start mopidris.service

Command line options

To see the command line options, call

python3 mopidris --help
usage: mopidris [-h] [-p PORT] [-r ATTEMPTS] [-t TIMEOUT] [-q] [-m] [-c FILE]
                [-i {tracklist,playlists}]
                [-d {debug,info,warning,error,critical}]
                [--debug-mopidy {debug,info,warning,error,critical}]
                [--debug-dbus {debug,info,warning,error,critical}]
                [--debug-websockets {debug,info,warning,error,critical}]
                [--debug-aiorun {debug,info,warning,error,critical}]
                [--debug-interfaces.base {debug,info,warning,error,critical}]
                [--debug-interfaces.root {debug,info,warning,error,critical}]
                [--debug-interfaces.player {debug,info,warning,error,critical}]
                [--debug-interfaces.tracklist {debug,info,warning,error,critical}]
                [--debug-interfaces.playlist {debug,info,warning,error,critical}]
                [HOST]

Connect a (remote) Mopidy instance to the local DBus.

positional arguments:
  HOST                  the remote host name or ip address
                        (default: localhost,
                         configfile key: host)

optional arguments:
  -h, --help            show this help message and exit
  -p PORT, --port PORT  the port number Mopidy is listening on
                        (default: 6680,
                         configfile key: port)
  -r ATTEMPTS, --retries ATTEMPTS
                        how often to retry to connect to Mopidy; if -1, retry
                        forever
                        (default: 5,
                         configfile key: reconnect_attempts)
  -t TIMEOUT, --timeout TIMEOUT
                        how long to wait between reconnection attempts
                        (default: 20,
                         configfile key: reconnect_timeout)
  -q, --can-quit        it is possible to quit this program from an
                        application; note, that the (remote) will keep running
                        (default: False,
                         configfile key: can_quit)
  -m, --no-mangle       do not split the Internet radio stream title at " - "
                        (default: True,
                         configfile key: mangle)
  -c FILE, --config FILE
                        read values from the configuration file
                        (default: <operating system dependend>,
                         a configfile key is not supported)

DBus Interfaces:
  -i {tracklist,playlists}, --interface {tracklist,playlists}
                        activate additional 'org.mpris.MediaPlayer2' DBus
                        interfaces (the 'org.mpris.MediaPlayer2' and
                        'org.mpris.MediaPlayer2.Player' interfaces are always
                        active)
                        (configfile key: interfaces - use one line for each
                        interface)

Debugging:
  -d {debug,info,warning,error,critical}, --debug {debug,info,warning,error,critical}
                        the general loglevel
                        (default: warning,
                         configfile key: debug)
  --debug-mopidy {debug,info,warning,error,critical}
                        the loglevel for the 'mopidy_asyncio_client' module
                        (default: follows --debug argument,
                         configfile key: debug_mopidy_asyncio_client)
  --debug-dbus {debug,info,warning,error,critical}
                        the loglevel for the 'dbus_next' module
                        (default: follows --debug argument,
                         configfile key: debug_dbus_next)
  --debug-websockets {debug,info,warning,error,critical}
                        the loglevel for the 'websockets' module
                        (default: follows --debug argument,
                         configfile key: debug_websockets)
  --debug-aiorun {debug,info,warning,error,critical}
                        the loglevel for the 'aiorun' module
                        (default: follows --debug argument,
                         configfile key: debug_aiorun)
  --debug-interfaces.base {debug,info,warning,error,critical}
                        the loglevel for the 'interfaces.base' module
                        (default: follows --debug argument,
                         configfile key: debug_interfaces.base)
  --debug-interfaces.root {debug,info,warning,error,critical}
                        the loglevel for the 'interfaces.root' module
                        (default: follows --debug argument,
                         configfile key: debug_interfaces.root)
  --debug-interfaces.player {debug,info,warning,error,critical}
                        the loglevel for the 'interfaces.player' module
                        (default: follows --debug argument,
                         configfile key: debug_interfaces.player)
  --debug-interfaces.tracklist {debug,info,warning,error,critical}
                        the loglevel for the 'interfaces.tracklist' module
                        (default: follows --debug argument,
                         configfile key: debug_interfaces.tracklist)
  --debug-interfaces.playlist {debug,info,warning,error,critical}
                        the loglevel for the 'interfaces.playlist' module
                        (default: follows --debug argument,
                         configfile key: debug_interfaces.playlist)

Configuration file:
Each line in the configuration file is a 'key = value' pair. The key is given
in the description of each parameter and the value can be any valid value.
Comments start with '#' and everything after is discarded.

Copyright (C) 2021, licensed under GPL 3.0 or later.

Copyright of this file

Copyright (C) 2021 Stephan Helma

This file is part of mopidris.

mopidris is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

mopidris is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with mopidris. If not, see https://www.gnu.org/licenses/.

Metadata

Release files for mopidris 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mopidris 0.9.1
File Size Uploaded Provenance Actions
mopidris-0.9.1.tar.gz 45.6 kB Without provenance Details for mopidris-0.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mopidris 0.9.1
File Interpreter ABI Platform Actions
mopidris-0.9.1-py3-none-any.whl Python 3 none any Details for mopidris-0.9.1-py3-none-any.whl

Total release size: 95.9 kB

Release files / mopidris-0.9.1.tar.gz

Download URL mopidris-0.9.1.tar.gz
Size 45.6 kB
Tags Source
SHA-256 checksum
How to use checksums
574fa2bbf6ffac4c5325fbf5d6bce9fba680ebc2b755fb87bd9ee4338dd74316
BLAKE2b-256 checksum
How to use checksums
9447d66778f457512e37c5331e0bebfa4ce8b07e468e1ae048a7dc374cc50f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Release files / mopidris-0.9.1-py3-none-any.whl

Download URL mopidris-0.9.1-py3-none-any.whl
Size 50.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd7c79fd11bf1354707cf97a376d48508b8b454bf3bd9e72aa52c2e9a48faefb
BLAKE2b-256 checksum
How to use checksums
173e59074a05780c1b9d4ba24fe4f5ddf1f2d9167a645474a17715b2a0662924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.10

Security for mopidris 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.9.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page