1 unstable release
0.6.0 | Feb 15, 2024 |
---|
#30 in #receiver
1MB
18K
SLoC
openlibspot
openlibspot is an open source client library for Spotify. It enables applications to use Spotify's service to control and play music via various backends, and to act as a Spotify Connect receiver. It is an alternative to the official and now deprecated closed-source libspotify
. Additionally, it will provide extra features which are not available in the official library.
Note: openlibspot only works with ALL Spotify Account Types.
Quick start
We're available on crates.io as the openlibspot package. Simply run cargo install openlibspot
to install openlibspot on your system. Check the wiki for more info and possible usage options.
After installation, you can run openlibspot from the CLI using a command such as openlibspot -n "openlibspot Speaker" -b 160
to create a speaker called openlibspot Speaker serving 160 kbps audio.
This fork
As the origin by plietar is no longer actively maintained, this organisation and repository have been set up so that the project may be maintained and upgraded in the future.
Documentation
Documentation is currently a work in progress, contributions are welcome!
There is some brief documentation on how the protocol works in the docs folder.
COMPILING.md contains detailed instructions on setting up a development environment, and compiling openlibspot. More general usage and compilation information is available on the wiki. CONTRIBUTING.md also contains our contributing guidelines.
If you wish to learn more about how openlibspot works overall, the best way is to simply read the code, and ask any questions you have in our Gitter Room.
Issues & Discussions
We have recently started using Github discussions for general questions and feature requests, as they are a more natural medium for such cases, and allow for upvoting to prioritize feature development. Check them out here. Bugs and issues with the underlying library should still be reported as issues.
If you run into a bug when using openlibspot, please search the existing issues before opening a new one. Chances are, we've encountered it before, and have provided a resolution. If not, please open a new one, and where possible, include the backtrace openlibspot generates on crashing, along with anything we can use to reproduce the issue, e.g. the Spotify URI of the song that caused the crash.
Building
A quick walkthrough of the build process is outlined below, while a detailed compilation guide can be found here.
Additional Dependencies
We recently switched to using Rodio for audio playback by default, hence for macOS and Windows, you should just be able to clone and build openlibspot (with the command below). For Linux, you will need to run the additional commands below, depending on your distro.
On Debian/Ubuntu, the following command will install these dependencies:
sudo apt-get install build-essential libasound2-dev
On Fedora systems, the following command will install these dependencies:
sudo dnf install alsa-lib-devel make gcc
openlibspot currently offers the following selection of audio backends:
Rodio (default)
ALSA
GStreamer
PortAudio
PulseAudio
JACK
JACK over Rodio
SDL
Pipe
Subprocess
Please check the corresponding Compiling entry on the wiki for backend specific dependencies.
Once you've installed the dependencies and cloned this repository you can build openlibspot with the default backend using Cargo.
cargo build --release
Packages
openlibspot is also available via official package system on various operating systems such as Linux, FreeBSD, NetBSD. Repology offers a good overview.
Usage
A sample program implementing a headless Spotify Connect receiver is provided. Once you've built openlibspot, run it using :
target/release/openlibspot --name DEVICENAME
The above is a minimal example. Here is a more fully fledged one:
target/release/openlibspot -n "openlibspot" -b 320 -c ./cache --enable-volume-normalisation --initial-volume 75 --device-type avr
The above command will create a receiver named openlibspot
, with bitrate set to 320 kbps, initial volume at 75%, with volume normalisation enabled, and the device displayed in the app as an Audio/Video Receiver. A folder named cache
will be created/used in the current directory, and be used to cache audio data and credentials.
A full list of runtime options is available here.
Please Note: When using the cache feature, an authentication blob is stored for your account in the cache directory. For security purposes, we recommend that you set directory permissions on the cache directory to 700
.
Disclaimer
Using this code to connect to Spotify's API is probably forbidden by them. Use at your own risk.
License
Everything in this repository is licensed under the MIT license.
Dependencies
~40–79MB
~1.5M SLoC