diff --git a/Dockerfile b/Dockerfile index d7875db..30310dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index e299570..03a0bd9 100644 --- a/README.md +++ b/README.md @@ -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? @@ -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 + - ICECAST_ADMIN=contact@domain.com + - ICECAST_HOSTNAME=my.ip.address + - ICECAST_LOCATION=New\ York - ICECAST_USERNAME=admin - ICECAST_PASSWORD=spotify - DARKICE_MOUNT_POINT=spotify @@ -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. diff --git a/configure.sh b/configure.sh index 7f87f52..229bca0 100644 --- a/configure.sh +++ b/configure.sh @@ -1,5 +1,12 @@ #!/bin/bash +echo "🔑 updating icecast config" + +sed -i -r "s/().*(<\\/admin>)/\1$ICECAST_ADMIN\2/ig" /etc/icecast2/icecast.xml +sed -i -r "s/().*(<\\/hostname>)/\1$ICECAST_HOSTNAME\2/ig" /etc/icecast2/icecast.xml +sed -i -r "s/().*(<\\/location>)/\1$ICECAST_LOCATION\2/ig" /etc/icecast2/icecast.xml +sed -i -r "s/().*(<\\/burst-on-connect>)/\10\2/ig" /etc/icecast2/icecast.xml + echo "🔑 updating icecast credentials" # update username @@ -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" diff --git a/librespot b/librespot new file mode 100644 index 0000000..3166e5a Binary files /dev/null and b/librespot differ diff --git a/spotifyd b/spotifyd deleted file mode 100644 index ac9e098..0000000 Binary files a/spotifyd and /dev/null differ diff --git a/spotifyd.conf b/spotifyd.conf deleted file mode 100644 index 58459a4..0000000 --- a/spotifyd.conf +++ /dev/null @@ -1,10 +0,0 @@ -[global] -device_name ="Daemon" -device_type = "computer" -backend = "pulseaudio" -bitrate = 320 -no_audio_cache = true -volume_normalisation = true -initial_volume = "90" -normalisation_pregain = -10 -zeroconf_port = 1234 diff --git a/start.sh b/start.sh index 818b20e..7268987 100644 --- a/start.sh +++ b/start.sh @@ -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"