hamishfagg / dockerfiles

42 stars 31 forks source link

Add librespot #26

Closed D3v01dZA closed 2 years ago

D3v01dZA commented 2 years ago

I've been using your snapclient docker image forever (thanks!) and I found something interesting a while back if you use spotify as an audio backend. You can make a snapserver with librespot included and usable directly as a source, which turns your whole snapserver into a Spotify Connect client so you can now open Spotify on your phone, select your snapserver and hit play, instead of going through Mopidy.

Its a neat feature to have and cuts my usage of Mopidy down quite a bit. I can share my Dockerfile if you are interested in what it looks like (it involves a single extra step to build the library without dbus interaction etc so it works in Docker).

hamishfagg commented 2 years ago

Yeah please share your file here, it'll probably save me some time :)

D3v01dZA commented 2 years ago

You should be able to just copy paste the first two images and then run the copy somewhere onto the path in the last but this is what I do today and then use it in a snapcast config

stream = spotify:///librespot?name=Spotify&username=username&password=password&devicename=name&bitrate=320


FROM alpine/git AS git
WORKDIR /librespot
RUN git clone --depth 1 --branch master https://github.com/librespot-org/librespot.git .

FROM rust as build-env
WORKDIR /app
COPY --from=git /librespot .
RUN cargo build --release --no-default-features

FROM alpine/curl AS curl
WORKDIR /download
RUN curl -L -o snapserver.deb https://github.com/badaix/snapcast/releases/download/v0.26.0/snapserver_0.26.0-1_amd64.deb

FROM ubuntu:20.04
WORKDIR /root
COPY --from=build-env /app/target/release/librespot /usr/bin/librespot
COPY --from=curl /download/snapserver.deb .
RUN apt update
RUN apt install -y /root/snapserver.deb
RUN rm snapserver.deb
ENTRYPOINT ["snapserver"]
hamishfagg commented 2 years ago

Hey ive uploaded an image at ivdata/snapserver:librespot, can you test it and let me know if its working?

Turns out its a PitA to cargo build for arm on a x86 machine, there's a bug in qemu

D3v01dZA commented 2 years ago

So I'm running this on x86 so not sure how useful I am but I did get this

snapserver | 2022-05-12 16-02-12.333 [Info] (LibrespotStream) (Spotify) /usr/bin/librespot: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /usr/bin/librespot)

D3v01dZA commented 2 years ago

Same error on the latest image

hamishfagg commented 2 years ago

I've just pushed a x64 image where librespot runs but spits this warning out:

WARN libmdns] Failed to register IPv6 receiver: Os { code: 19, kind: Uncategorized, message: "No such device" }

Do you get the same / is it a real issue? I'm currently building the arm image but it takes ages.

D3v01dZA commented 2 years ago

Its working, I just booted it up.

The IPV6 message happens for me too but I explicitly have v6 disabled in Docker, which should be the cause of it.

hamishfagg commented 2 years ago

Awesome! I'm going to close unless you have any other issues. I'm working on moving to alpine images, so I will merge librespot into the main image when i do that for snapserver.

hamishfagg commented 2 years ago

Could you please test ivdata/snapserver:alpine for librespot support? This is a much smaller image (~10MB vs ~100MB) so I think I will switch over to the alpine images if it works.

EDIT: FWIW I've just set up librespot because it looks cool :) and the alpine image is working for me

D3v01dZA commented 2 years ago

I played a long time trying to find something that would let me sensibly use a streaming music app (although sometimes I wish I had my own library) and librespot is by far and away the best way I've found.

I tested the image, and it seems to work exactly the same as the the one tagged as librespot

hamishfagg commented 2 years ago

I'm having an issue where snapcast (usually) segfaults when I select the snapserver as my output device in any spotify client. Normally restarting stuff and fiddling around I can get it to connect after a while but I haven't worked out what the solution is yet. When I get time I'll try my old :librespot image for the same thing.

Dunno if you've run into this?

D3v01dZA commented 2 years ago

I don't think I've seen this yet. Just to be sure, would the segfault show up in my docker logs or would I need to go look at another file to determine that's what happened? I have seen my libspotify disconnect from spotify connect before though.