spotifyd icon indicating copy to clipboard operation
spotifyd copied to clipboard

API?

Open AndreKR opened this issue 3 years ago • 4 comments

Does spotifyd have an API to start playback? I can't find anything in the wiki. If I need to use Spotify's (mostly broken) web API, then what is the purpose of spotifyd, I can just as well use librespot directly?

AndreKR avatar Mar 28 '22 00:03 AndreKR

You could use the dbus/mpris interface in combination with playerctl. Although I think you have to build it on your own with the mpris feature flag because the default build doesn't support it but I'm not sure about it.

https://github.com/Spotifyd/spotifyd/blob/82bc875efc4e1b2e0e1c2e489e3dd4f2e6a5b97b/docs/src/installation/Feature-flags.md https://spotifyd.github.io/spotifyd/installation/Ubuntu.html

Exceen avatar Mar 28 '22 05:03 Exceen

spotifyd is mostly meant as a player for spotify not a client. A client is in charge of choosing the songs etc. You can indeed use dbus to play/pause/next/prev but you cannot select a song this way

robinvd avatar Mar 28 '22 14:03 robinvd

Then why does it exist? It uses librespot as a dependency to provide exactly the same functionality as librespot? Can it do anything that librespot cannot?

AndreKR avatar Mar 28 '22 14:03 AndreKR

spotifyd has some additional features, like MPRIS support, D-Bus Keyring support for passwords and a nice configuration file (potentially others, I can't think of anything else at the moment). However, depending on your use case, you may just be fine using the original librespot binary application, which does most of the stuff more or less the same as spotifyd and is usually more up-to-date with the current bug fixes in librespot itself. So it really depends on your needs.

(Sidenote: I'm just a regular user of spotifyd, so take that with a grain of salt.)


Adding to what @robinvd said: You can actually change tracks (although apparently not initiate the playback) via the dbus API:

dbus-send --print-reply=literal --dest=org.mpris.MediaPlayer2.spotifyd /org/mpris/MediaPlayer2 \
org.mpris.MediaPlayer2.Player.OpenUri "string:spotify:track:6VZ7N7Q2C5YEwLh4EhIWf8"

Note that this only calls the Web API itself in the background, though...

eladyn avatar Mar 29 '22 17:03 eladyn

I don't think that there's anything that needs to be done here? Feel free to reopen, if you feel differently!

eladyn avatar Sep 09 '22 14:09 eladyn