Skip to content

Commit

Permalink
migrate to librespot
Browse files Browse the repository at this point in the history
  • Loading branch information
meiser79 committed Jan 13, 2025
1 parent 3f57b8a commit a533ed5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ RUN apt update && apt upgrade -y \
&& apt install -y \
darkice \
icecast2 \
iproute2 \
pulseaudio \
wget \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ~/.cache /root/.cache

COPY darkice.cfg /etc/darkice.cfg

COPY spotifyd.conf /etc/spotifyd.conf

COPY spotifyd /usr/local/bin/spotifyd
RUN chmod +x /usr/local/bin/spotifyd
COPY librespot /usr/local/bin/librespot
RUN chmod +x /usr/local/bin/librespot

COPY configure.sh /usr/local/bin/configure.sh
RUN chmod +x /usr/local/bin/configure.sh
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Stream your Spotify collection

A docker image that creates a new device on Spotify (called "Daemon"), which streams what you're listening to Icecast.

It uses the excellent [spotifyd](https://github.com/Spotifyd/spotifyd).
It uses the excellent [librespot](https://github.com/librespot-org/librespot).

## How?

Expand All @@ -16,11 +16,16 @@ services:
spotify-stream:
container_name: spotify-stream
environment:
- SPOTIFY_DEVICE_NAME=Daemon
- LIBRESPOT_DEVICE_NAME=Daemon
# possible values: audiodongle, avr, computer, smartphone, speaker, stb, tablet, tv
- SPOTIFY_DEVICE_TYPE=computer
- SPOTIFY_INITIAL_VOLUME=90
- SPOTIFY_ZEROCONF_PORT=1234
- LIBRESPOT_DEVICE_TYPE=computer
- LIBRESPOT_CACHE=/spotify-stream/cache
- LIBRESPOT_INITIAL_VOLUME=90
- LIBRESPOT_ZEROCONF_IP=192.168.1.10
- LIBRESPOT_ZEROCONF_PORT=1234
- [email protected]
- ICECAST_HOSTNAME=my.ip.address
- ICECAST_LOCATION=New\ York
- ICECAST_USERNAME=admin
- ICECAST_PASSWORD=spotify
- DARKICE_MOUNT_POINT=spotify
Expand All @@ -29,15 +34,17 @@ services:
image: meiser79/spotify-stream:latest
network_mode: host
restart: unless-stopped
volumes:
- ./cache:/spotify-stream/cache
```

Then connect to the stream via `http://my.ip.address:8000/spotify`.

## Disclaimer

[spotifyd](https://github.com/Spotifyd/spotifyd) binary was compiled via `cargo build --release --features pulseaudio_backend` and was included here to accelerate building time. You should compile it by yourself.
[librespot](https://github.com/librespot-org/librespot) binary was compiled via `cargo build --release --no-default-features --features "pulseaudio-backend with-libmdns"` and was included here to accelerate building time. You should compile it by yourself.

## Legal
Spotify Stream is licensed under MIT.
Spotify Stream is licensed under MIT, it's based on [Trugamr's project](https://github.com/Trugamr/spotify-stream).

SPOTIFY is a trademark of Spotify AB.
13 changes: 7 additions & 6 deletions configure.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

echo "🔑 updating icecast config"

sed -i -r "s/(<admin>).*(<\\/admin>)/\1$ICECAST_ADMIN\2/ig" /etc/icecast2/icecast.xml
sed -i -r "s/(<hostname>).*(<\\/hostname>)/\1$ICECAST_HOSTNAME\2/ig" /etc/icecast2/icecast.xml
sed -i -r "s/(<location>).*(<\\/location>)/\1$ICECAST_LOCATION\2/ig" /etc/icecast2/icecast.xml
sed -i -r "s/(<burst-on-connect>).*(<\\/burst-on-connect>)/\10\2/ig" /etc/icecast2/icecast.xml

echo "🔑 updating icecast credentials"

# update username
Expand All @@ -19,11 +26,5 @@ sed -i -r "s/^mountPoint.*$/mountPoint = $DARKICE_MOUNT_POINT/" /etc/darkice.cfg
sed -i -r "s/^name.*$/name = $DARKICE_NAME/" /etc/darkice.cfg
sed -i -r "s/^description.*$/description = $DARKICE_DESCRIPTION/" /etc/darkice.cfg

echo "🔨 updating spotifyd config"
sed -i -r "s/^device_name.*$/device_name = \"$SPOTIFY_DEVICE_NAME\"/" /etc/spotifyd.conf
sed -i -r "s/^device_type.*$/device_type = \"$SPOTIFY_DEVICE_TYPE\"/" /etc/spotifyd.conf
sed -i -r "s/^initial_volume.*$/initial_volume = \"$SPOTIFY_INITIAL_VOLUME\"/" /etc/spotifyd.conf
sed -i -r "s/^zeroconf_port.*$/zeroconf_port = $SPOTIFY_ZEROCONF_PORT/" /etc/spotifyd.conf

echo "🌊 configuration done"
echo -e "\n---------------------\n"
Binary file added librespot
Binary file not shown.
Binary file removed spotifyd
Binary file not shown.
10 changes: 0 additions & 10 deletions spotifyd.conf

This file was deleted.

9 changes: 7 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ su - ubuntu -c "darkice -c /etc/darkice.cfg & sleep 2 && disown"

echo -e $separator

echo "🎵 starting spotifyd"
su - ubuntu -c "spotifyd --no-daemon --config-path=/etc/spotifyd.conf"
echo "🔨 updating icecast's metadata"
wget -q -O - --user $ICECAST_USERNAME --password $ICECAST_PASSWORD http://localhost:8000/admin/metadata?mount=/$DARKICE_MOUNT_POINT\&mode=updinfo\&song="${DARKICE_NAME/\\/}"

echo -e $separator

echo "🎵 starting librespot"
su - ubuntu -c "librespot --name $LIBRESPOT_DEVICE_NAME --device-type $LIBRESPOT_DEVICE_TYPE --backend pulseaudio --bitrate 320 --cache $LIBRESPOT_CACHE --disable-audio-cache --enable-volume-normalisation --initial-volume $LIBRESPOT_INITIAL_VOLUME --zeroconf-interface $LIBRESPOT_ZEROCONF_IP --zeroconf-port $LIBRESPOT_ZEROCONF_PORT --autoplay off"

0 comments on commit a533ed5

Please sign in to comment.