Skip to content

Instantly share code, notes, and snippets.

@helgibbons
Last active May 14, 2025 10:47
Show Gist options
  • Select an option

  • Save helgibbons/9668655cbbf252ef3d21f1095c9f4ff0 to your computer and use it in GitHub Desktop.

Select an option

Save helgibbons/9668655cbbf252ef3d21f1095c9f4ff0 to your computer and use it in GitHub Desktop.
How to get mopidy-spotify working in 2025

I started from the most recent version of Raspberry Pi OS (with recommended software) on a Pi Zero 2 W.

Installing Mopidy

First install the repackaged installer from pimoroni/pirate-audio#105. This is now merged into main so you can install it with

git clone https://github.com/pimoroni/pirate-audio
cd pirate-audio/mopidy
./install.sh

and

sudo reboot

Once mopidy starts up, you should see the URL of the device showing on the screen. You can also go to hostname.local:6680 to connect.

If you want to play music from Spotify on Pirate Audio, it will take a few extra steps!

Installing mopidy-spotify

Next we need to install the mopidy-spotify plugin. The most recent instructions on how to do this can be found here: https://github.com/mopidy/mopidy-spotify

This plugin relies upon the GStreamer Rust Plugin, which needs to be compiled from source. Spotify have now disabled username and password login so we need to install a forked version which supports token based login.

Don't try and compile it yourself on a Raspberry Pi, it is pain. Instead, grab a pre-compiled binary that the nice people behind spotify-mopidy have provided: https://github.com/kingosticks/gst-plugins-rs-build/releases. You will need the arm64 file for recent models of Raspberry Pi, download it with:

wget https://github.com/kingosticks/gst-plugins-rs-build/releases/download/gst-plugin-spotify_0.14.0-alpha.1-1/gst-plugin-spotify_0.14.0.alpha.1-1_arm64.deb

and then to unpack and install it:

sudo dpkg -i gst-plugin-spotify_0.14.0.alpha.1-1_arm64.deb

Run the following command to check that the plugin is correctly installed:

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

Switch to our virtual environment:

source ~/.virtualenvs/mopidy/bin/activate

Install mopidy-spotify:

python3 -m pip install mopidy-spotify==5.0.0a3

Generate a client_id and client_secret from here: https://mopidy.com/ext/spotify/#authentication . You will need a Spotify Premium subscription.

Edit the mopidy config file:

sudo nano ~/.config/mopidy/mopidy.conf

Scroll down to the bottom, and add your details to the [spotify] section. It should look something like this:

[spotify]
enabled = true
client_id = replace_with_your_client_id
client_secret = replace_with_your_secret

Then it's probably a good idea to sudo reboot again.

You may need to authorise the Spotify plugin through the settings of the web interface page if you've not done this already.

Troubleshooting

If you have no audio try editing your config.txt (sudo nano /boot/firmware/config.txt) and turning off onboard audio by adding the following line to the end of the file:

dtparam=audio=off

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment