TimotheeGerber / spotify-connect

Log on your Spotify Connect compatible devices through the terminal
MIT License
8 stars 1 forks source link

Spotify Connect

Use spotify-connect to authenticate yourself on remote devices. Theses devices will then be controllable by the Spotify Web API (through rspotify or spotify-tui for example).

I don't have any official device with Spotify Connect. I made this tool to register my librespot receivers. So, it has not been tested on official hardware. It may work. But it will certainly fail.

Installation

There is no package yet. There is even no crate yet. Early-stage at its highest!

Fortunately, we can rely on git and cargo for the installation:

git clone https://github.com/TimotheeGerber/spotify-connect.git
cd spotify-connect
cargo install --path .

Usage

spotify-connect <IP> <PORT> [PATH]

Automatic discovery of devices is not implemented yet. You have to find the IP address of your receiver, the PORT Spotify Connect is listening to and, optionally, the PATH to the ZeroConf API on the device web server. The PATH should always start with a / character.

The following avahi command should provide everything needed:

avahi-browse --resolve _spotify-connect._tcp

If it is the first time you use spotify-connect, your Spotify credentials will be asked in a OAuth flow. You have to open the given URL into your browser, authenticate on the official Spotify website (if you are not already logged) and accept the demand. Reusable credentials will be automatically cached for future spotify-connect calls. On Linux, the credentials should be cached in $HOME/.cache/spotify-connect/credentials.json.

Reusable credentials are provided by Spotify and are encrypted. Your password is not stored as plain text. However, you can set the permissions of the cache directory to 700 to improve security.

If the default authentication method is not working on your devices, you can try alternative methods with the --auth-type <AUTH_TYPE> option.

spotify-connect --auth-type access-token <IP> <PORT> [PATH]

Type spotify-connect --help to see the list of all authentication methods currently implemented.

Note that Spotify has deprecated the username/password flow. Please, consider using the OAuth flow instead.

Roadmap

The following steps are planned:

Disclaimer

I did not read all Spotify legal notices, but I am pretty sure that using this tool is forbidden by them. Use at your own risk! And if you work at Spotify, please, don't hurt me!

Thanks

Many thanks to the people behind librespot! Chunks of code are largely inspired by their excellent work.