Spotifyd / spotifyd

A spotify daemon
https://spotifyd.rs
GNU General Public License v3.0
9.8k stars 447 forks source link

API? #1072

Closed AndreKR closed 2 years ago

AndreKR commented 2 years ago

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?

Exceen commented 2 years ago

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

robinvd commented 2 years ago

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

AndreKR commented 2 years ago

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?

eladyn commented 2 years ago

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 commented 2 years ago

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