sweisgerber / docker-snapcast

Snapcast Multiroom audio docker image
14 stars 7 forks source link

Implement librespot credential caching #13

Open ironcrafter54 opened 1 month ago

ironcrafter54 commented 1 month ago

Currently if you restart the container the cached librespot credentials will not be stored, if implementation/documentation on how to properly make these cached credentials persistent that would be great. This is what the librespot readme says about this: Usage A sample program implementing a headless Spotify Connect receiver is provided. Once you've built librespot, run it using :

target/release/librespot --name DEVICENAME The above is a minimal example. Here is a more fully fledged one:

target/release/librespot -n "Librespot" -b 320 -c ./cache --enable-volume-normalisation --initial-volume 75 --device-type avr The above command will create a receiver named Librespot, 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.

sweisgerber commented 1 month ago

This configuration can get done in snapserver.conf.

My image starts snapserver with: /usr/bin/snapserver --config /config/snapserver.conf $SNAPSERVER_OPTS

This file should be accessible in your mounted config folder, if you used https://github.com/sweisgerber/docker-snapcast/blob/d9d6e802d66a535c445292518f268187873200fe/docker-compose.example.yml#L24 as a template.

Simply configure your desired params as documented here: https://github.com/badaix/snapcast/blob/develop/doc/configuration.md#librespot, e.g. by placing them in -c ./config/librespot-cache

It's all in a snapcast source = ... line

sweisgerber commented 1 month ago

https://github.com/sweisgerber/docker-snapcast/blob/main/root/defaults/snapserver.conf gets copied to /config/snapserver.conf on container first-boot.

ironcrafter54 commented 1 month ago

Thanks I will try to set this up.