Use of the command line to start Spotify-Playlist?

Can I use the command line to start a Spotify-Album?

Things I’ve tried:

volumio play open.spotify.com/album/5gpWQyfq … B4fqejgdXw

volumio play “https://open.spotify.com/album/5gpWQyfqy3zAh52aVNWuQb?si=4hDPlf-AQ6aZB4fqejgdXw

volumio play spotify:album:5gpWQyfqy3zAh52aVNWuQb

volumio play “spotify:album:5gpWQyfqy3zAh52aVNWuQb”

The answer is always “curl: (52) Empty reply from server”

I´m not shure about the syntax of the command-line-client…

Cheers
Kristian

I think the CLI client acts on the current queue, so you would have to add your spotify album to the queue before attempting to play it.

Damn… you’re right.

I tried a bit bit local files, but I think I just restartet and stopped the existing queue. :blush:

Is there a way to control the player and the queue apart from the UI?

I want to build a musicplayer for the kids using RFID-Cards to listen to their music.
There are other how-tos online, but I they use vlc-player. Spotify would be a great argument to use Volumio.

Have a look at the APIs volumio.github.io/docs/API/API_Overview.html

How far did you come with this? I also built a music box for my kids with RFID cards but now I want to upgrade the whole thing to Spotify. Help is appreciated, but I will also have a look into the API, but I am not an programming expert :wink:

Hi there, with a significant amount of delay:
I can confirm there is a way of telling volumio to play a spotify playlist via the command-line.

I’ll post it here for the desparate users coming here in hope of finding a solution - like me, before I successfully “hacked” into the details of the API.

I’m currently on volumio 2.915 using the “Spotify 2.0.2” plugin.
The whole stuff -as mentioned elsewhere- requires a Spotify premium account.

In a nutshell, what does the trick is to use

  • volumio’s REST API, namingly the “replaceAndPlay” call
  • a request BODY that has the correct Spotify playlist URI in it
  • having a working version of CURL (should be pre-installed if you’re using a linux flavour)

In order for the whole shebang to work, you’ll need to know the playlist URI.
That’s a bit cumbersome but actually not too hard.
Open a webbrowser and put in the following URL in the address box:
http://YOUR-VOLUMIO-IP/api/v1/browse?uri=spotify/playlists

…and of course, replace YOUR-VOLUMIO-IP with the IP address of your volumio player device.

If all works well, you’ll receive a bunch of “json-formatted text”.
Inside that curly-bracked-colon mess, you’ll probably be able to spot something similar to
,"type":"playlist","title":"XXXYYYZZZ",
where XXXYYYZZ stands for a playlist name of one of your Spotify playlists.

Now, not too far away from this, there will also be a text looking like
"uri":"spotify:user:spotify:playlist:xxxxxxxxxxxxxxxxxxxxx"}
…with “xxxxxxx” being a sequence of characters like “5XyZA4EFghZT54dKGt” or similar.
THAT part (starting with the “spotify:user…” up to the closing quotes) is the playlist URI we will need
to use later. Copy-paste it somwhere.

Next, we’ll be crafting a curl command to send to volumio.
I’ll first give an example of how the whole command-line needs to look like:

curl -i --header "Content-Type: application/json" --data '{ "service": "spop","type": "playlist", "title": "PLAYLISTNAME","uri": "spotify:user:spotify:playlist:XXXXXXXXXXXX"}' http://YOUR-VOLUMIO-IP/api/v1/replaceAndPlay

You’ll have to replace

  • PLAYLISTNAME …with the title of the playlist (the part where I said “XXXYYYZZZ” above)
  • spotify:user:spotify:playlist:XXXXXXXXXXXX …with the URI thing, the part I told you to copy-paste above :slight_smile:
  • YOUR-VOLUMIO-IP …with the IP address of your volumio player, just like you did in the webbrowser’s address bar above

Once your command is ready, hit ENTER and keep fingers crossed.
If something goes wrong, check that

  • curl is installed
  • no quote, bracket or colon is missing from the text replacement action
  • the IP of your volumio player is correct and “ping”-able
  • the URI was copy-pasted entirely (no characters missing)

Hope this helps.
Cheers, Thomas

Hi,
Thanks for the details.
I get this error:
curl: (7) Failed to connect to 192.168.1.49 port 80: Connection refused
I can browse to http://192.168.1.49/ , I don’t see why it refuses the connection locally
Any idea?