Skip to main content

mopidy-spotify

Latest PyPI version CI build status Test coverage

Mopidy extension for playing music from Spotify.

Status

[!WARNING] Spotify has recently disabled streaming via third-party access tokens, like the one Mopidy-Spotify uses. Current workarounds are to obtain a new credentials.json file using librespot and put that where Mopidy-Spotify expects it. Details at #437.

[!WARNING] Spotify has introduced refresh token expiration as described in this blogpost. In practice this means you'll have to re-authenticate every six months going forward.

[!WARNING] Spotify have recently disabled username and password login for playback (#394) and we now use access token login. You no longer need to provide your Spotify account username or password.

Mopidy-Spotify currently has no support for the following:

  • Seeking
  • Gapless playback
  • Volume normalization
  • Saving items to My Music (#108) - possible via web API
  • Podcasts (#201) - now possible
  • Radio (#9) - unavailable?
  • Spotify Connect (#14)

Working support for the following features is currently available:

  • Playback
  • Search
  • Playlists (read-only)
  • Top lists and Your Music (read-only)
  • Lookup by URI

Dependencies

  • A Spotify Premium subscription. Mopidy-Spotify will not work with Spotify Free, just Spotify Premium.

  • Mopidy >= 3.4. The music server that Mopidy-Spotify extends.

  • gst-plugins-spotify, the GStreamer Rust Plugin for Spotify playback, based on librespot. This plugin is not yet available from apt.mopidy.com. It must be either built from source or Debian packages are available for some platforms.

We currently prefer a forked version of this plugin which provides better logging. Details in release notes here.

Verify the GStreamer spotify plugin is correctly installed:

gst-inspect-1.0 spotifyaudiosrc | grep Version | awk '{print $2}'

Installation

Install by running:

sudo python3 -m pip install --break-system-packages mopidy-spotify

Configuration

Before starting Mopidy, you must visit https://mopidy.com/ext/spotify/#authentication to authorize this extension against your Spotify account:

[spotify]
client_id = ... client_id value you got from mopidy.com ...
client_secret = ... client_secret value you got from mopidy.com ...

[!IMPORTANT] Remove any credentials.json file you may have manually created. You must also do this if you need to reauthorize the extension.

The following configuration values are available:

  • spotify/enabled: If the Spotify extension should be enabled or not. Defaults to true.

  • spotify/client_id: Your Spotify application client id. You must provide this.

  • spotify/client_secret: Your Spotify application secret key. You must provide this.

  • spotify/bitrate: Audio bitrate in kbps. 96, 160, or 320. Defaults to 160.

  • spotify/volume_normalization: Whether volume normalization is active or not. Defaults to true.

  • spotify/timeout: Seconds before giving up waiting for search results, etc. Defaults to 10.

  • spotify/allow_cache: Whether to allow caching. The cache is stored in a "spotify" directory within Mopidy's core/cache_dir. Defaults to true.

  • spotify/cache_size: Maximum cache size in MiB. Set to 0 for unlimited. Defaults to 8192.

  • spotify/allow_playlists: Whether or not playlists should be exposed. Defaults to true.

  • spotify/search_album_count: Maximum number of albums returned in search results. Number between 0 and 50. Defaults to 20.

  • spotify/search_artist_count: Maximum number of artists returned in search results. Number between 0 and 50. Defaults to 10.

  • spotify/search_track_count: Maximum number of tracks returned in search results. Number between 0 and 50. Defaults to 50.

  • spotify/username: Deprecated since v5.0.0. Please remove from your configuration file.

  • spotify/password: Deprecated since v5.0.0. Please remove from your configuration file.

Project resources

Development

Set up development environment

Clone the repo using, e.g. using gh:

gh repo clone mopidy/mopidy-spotify

Enter the directory, and install dependencies using uv:

cd mopidy-spotify/
uv sync

Running tests

To run all tests and linters in isolated environments, use tox:

tox

To only run tests, use pytest:

pytest

To format the code, use ruff:

ruff format .

To check for lints with ruff, run:

ruff check .

To check for type errors, use pyright:

pyright .

Making a release

To make a release to PyPI, go to the project's GitHub releases page and click the "Draft a new release" button.

In the "choose a tag" dropdown, select the tag you want to release or create a new tag, e.g. v0.1.0. Add a title, e.g. v0.1.0, and a description of the changes.

Decide if the release is a pre-release (alpha, beta, or release candidate) or should be marked as the latest release, and click "Publish release".

Once the release is created, the release.yml GitHub Action will automatically build and publish the release to PyPI.

Credits

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mopidy_spotify-5.0.1.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mopidy_spotify-5.0.1-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file mopidy_spotify-5.0.1.tar.gz.

File metadata

  • Download URL: mopidy_spotify-5.0.1.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mopidy_spotify-5.0.1.tar.gz
Algorithm Hash digest
SHA256 54877fec64fe2201d6dfe12a7c5815c3f3a66cacc14cd44f87fc0824c715b16e
MD5 c471db5bde749a9209b27e1183d82f52
BLAKE2b-256 66880fe5a503aae1e237c154546cd086f3a4d5c1ec8cabc63eff2c7296b21c4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mopidy_spotify-5.0.1.tar.gz:

Publisher: release.yml on mopidy/mopidy-spotify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mopidy_spotify-5.0.1-py3-none-any.whl.

File metadata

  • Download URL: mopidy_spotify-5.0.1-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mopidy_spotify-5.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12e6241f1f736c81f61f5693403ff3c960dfed573187657ddb2a5d0ce6d8de96
MD5 93dc10c35370798d4e2bf68513525dfe
BLAKE2b-256 92478571581ac6f049d433802e82e5a334873ea4afe7160e7f5762a53cee927f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mopidy_spotify-5.0.1-py3-none-any.whl:

Publisher: release.yml on mopidy/mopidy-spotify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

5.0.1 This release

2 files

5.0.0

2 files

4.1.1

2 files

4.1.0

2 files

4.0.1

2 files

4.0.0

2 files

3.1.0

2 files

3.0.0

2 files

2.3.1

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.3

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.1.0

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