MiczFlor/RPi-Jukebox-RFID

πŸ› | Spotify does not work anymore

hyperbit00 opened this issue Β· 145 comments

Bug

What I did

My Working Phoniebox stops working since today.
Spotify integration does not work. only local playback works

I Changed nothing. Works weeks before like a charm.
Spotify Premium is Valid

What happened

May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.__main__ Starting Mopidy 3.2.0
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.config Loading config from builtin defaults
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy-local.conf
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy.conf
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.config Loading config from file:///etc/mopidy/mopidy.conf
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.config Loading config from command line options
May 16 19:46:47 phoniebox mopidy[2207]: ERROR    [MainThread] mopidy.internal.log Loading logging config '/etc/mopidy/logging.conf' failed. 'formatters'
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.__main__ Enabled extensions: local, spotify, file, mpd, iris, m3u, stream, softwaremixer, http
May 16 19:46:47 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.__main__ Disabled extensions: none
May 16 19:46:48 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Starting Mopidy mixer: SoftwareMixer
May 16 19:46:48 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Mixer volume set to 30
May 16 19:46:48 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Starting Mopidy audio
May 16 19:46:48 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Starting Mopidy backends: FileBackend, M3UBackend, StreamBackend, SpotifyBackend, LocalBackend
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [Audio-2] mopidy.audio.actor Audio output set to "alsasink"
May 16 19:46:49 phoniebox mopidy[2207]: ERROR    [SpotifyEventLoop] spotify.session Spotify login error: <ErrorType.USER_NEEDS_PREMIUM: 15>
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [SpotifyBackend-6] mopidy_spotify.web Logged into Spotify Web API as XXXXXXXXXX
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Starting Mopidy core
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Starting Mopidy frontends: IrisFrontend, HttpFrontend, MpdFrontend
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [IrisFrontend-11] mopidy_iris.core Starting Iris 3.54.2
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [HttpFrontend-13] mopidy.http.actor HTTP server running at [0.0.0.0]:6680
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [MainThread] mopidy_mpd.actor MPD server running at [0.0.0.0]:6600
May 16 19:46:49 phoniebox mopidy[2207]: INFO     [MainThread] mopidy.commands Starting GLib mainloop


May 16 19:49:29 phoniebox mopidy[2207]: INFO     [MpdSession-278] mopidy_mpd.session New MPD connection from [127.0.0.1]:34620
May 16 19:49:29 phoniebox mopidy[2207]: INFO     [SpotifyBackend-6] mopidy_spotify.lookup Failed to lookup 'spotify:album:0XXX': Session must be logged in and online to load objects: <ConnectionState.LOGGED_O
May 16 19:49:29 phoniebox mopidy[2207]: INFO     [MpdSession-279] mopidy_mpd.session New MPD connection from [127.0.0.1]:34622

I think its a problem an is described here -> ? https://github.com/mopidy/mopidy-spotify

"As promised last month, Spotify disabled access to libspotify on 16/05/2022. As of today, seven years after libspotify was deprecated, there is still no official replacement library available."

I think this is a major problem for every Phonebox/Spotify version

Thanks for reporting this.

Looks like this is a real showstopper, we need to look into that.

varac commented

Holy shite, yes please prioritized this, I think this breaks every other phoniebox out there (including mine :/)

Can confirm. We have 2 Phonieboxes for our children and both stopped playing spotify over night.

Confirmed by 5 boxes and 5 sad children. There will be no quick way around it. We all hoped that day would never come, but it finally has come and there is not much one can do as long as spotify does not reconsider its decision. At least the non-spotify part is still working.

Holy shite, yes please prioritized this, I think this breaks every other phoniebox out there (including mine :/)

Unfortunately I don’t think that there will be quick a solution to this, because Spotify disabled the support of libspotify.

The people from mopidy-spotify (which Phoniebox relies on) are currently working on solutions (see mopidy/mopidy-spotify#110 (comment)), but no idea, when a solution will be available.

Is it out of the question to use another API or SDK for Spotify on Phoniebox? It's really depressing to lose that unique selling point. I didn't see it coming, either.

Is it out of the question to use another API or SDK for Spotify on Phoniebox? It's really depressing to lose that unique selling point. I didn't see it coming, either.

See #1815 (comment)

Same here spotify is not working anymore. Is there any alternative API or SDK to replace mopidy?

whats about this: https://lib.rs/crates/gst-plugin-spotify
(found here mopidy/mopidy-spotify#110 (comment))

^that might work, see how to install https://qengineering.eu/install-gstreamer-1.18-on-raspberry-pi-4.html
( I hadn't found time to try ;( )

Same here spotify is not working anymore. Is there any alternative API or SDK to replace mopidy?

whats about this: https://lib.rs/crates/gst-plugin-spotify (found here mopidy/mopidy-spotify#110 (comment))

Current implementation relies on mopidy in the Spotify edition (also for non Spotify functions), so from my point of view we should wait for an update of mopidy-spotify. Hopefully this would be only an update of mopidy-spotify.

But if anyone comes up with a different solution and proposes a PR, we could also check if this is the way we want to go.

As we are currently working on a new and shiny version 3 we need to check the implications in https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/spotify as well.

@pabera @ChisSoc @Groovylein @MiczFlor

As we are currently working on a new and shiny version 3 we need to check the implications in https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/spotify as well.

^^I've seen there is already alottah python inside, this might be handsome, I'll try...

https://pypi.org/project/spotify/

As we are currently working on a new and shiny version 3 we need to check the implications in https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/spotify as well.

I've tested the development environment for Spotify yesterday and it works 🀞
We are using https://github.com/librespot-org/librespot-java, which is using the Spotify Web-API

As we are currently working on a new and shiny version 3 we need to check the implications in https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/spotify as well.

I've tested the development environment for Spotify yesterday and it works 🀞 We are using https://github.com/librespot-org/librespot-java, which is using the Spotify Web-API

yeah, would be so nice to have a kind of working version, so guys can swtich to future 3 ;)

Hey Guys, that would be so so so awesome if you would be able to find an alternative solution! You would be a star for so many Kids and Dads! :-)

I'm to stupid for active coding contribution. It would be awesome to get an alternative for my son. We both created a huge amount of cards with his favorite audiobooks. Therefore it would be great if you professionals find a way to solve the problem.

As we are currently working on a new and shiny version 3 we need to check the implications in https://github.com/MiczFlor/RPi-Jukebox-RFID/tree/future3/spotify as well.

I've tested the development environment for Spotify yesterday and it works 🀞 We are using https://github.com/librespot-org/librespot-java, which is using the Spotify Web-API

How mature is the future3/spotify branch? Can it be merged and released yet?

How mature is the future3/spotify branch? Can it be merged and released yet?

Unfortunately it isn't stable at all. The player management and the whole WebApps are not ready for Spotify yet.

Can we get a merge of future3/dev and spotify? Even if not stable and no web-app, i guess you will get a lot of testers :-)

Just came to the discussions to find out, why my daughter's Phoniebox stopped working. And now - oh my, what a catastrophe πŸ˜₯, our Phoniebox is entirely based on Spotify, I made over 50 cards. Hopefully, it will work again in Future, shame on Spotify to just cut the access.

maahn commented

This was quite shocking news so I thought about alternatives out of desperation: I have an LMS SqueezeboxServer server on another Raspberry Pi (with working Spotify support), so I installed piCorePlayer on my Phoniebox to use it as an LMS Squeezebox Client, and wrote a script to use RFID tags for starting Spotify playlists.

Of course, this is not supposed to be a replacement for Phoniebox, just a quick and dirty fix to get Spotify working again quickly. I hope you find a better solution soon! Until then, if someone is desperate enough to try it out, the script and instructions are here https://github.com/maahn/piCorePhonie

wrote a script to use RFID tags for starting Spotify playlists.

nice!!
I'm on a just python script, back to basics, I started yesterday, reading the usb rfid number works,
have less time but will be ready hopefully soon

A few words about the future3/spotify branch: This is not just adding Spotify. This branch massively changes (and improves) the way the Jukebox interfaces with the backend players. Previously there has only been one: MPD, and now there need to be multiple. So even future3/develop and future3/spotify are not compatible at the moment and need to be merged, which is a bit of work.

hmm here are some thoughts from my side: Instead of trying to create an Eierlegende Wollmilchsau, maybe be should take a step back and aim for a simple back-to-the-roots version: A codebase that allows playing of spotify based on RFID cards.

oh deer ;)
it kind of works, but not really ;)
daughter is happy I converted her box to a just Spotiy Connect Client with raspotify
she's using her laptop to start an album and closes it after it's playing through the pi -> audio jack -> partybox
works flawless since 2 days ;) ... she's old enough to get in touch to the whole spotify world...

for her little brother -> rfid cards kind of work ...
see the gist, feel free to do any better ;) I'm not a soo experienced python guy ...
https://gist.github.com/sonicdee/bf5f655669ef6900b72c54f0c7696d32
it's using raspotify also, and spotipy to control it,
but
I'm running in an issue the raspotify device is not active on next day, so it can't be controlled anymore ;(
^^ maybe it can be done all inside librespot better !?

I stuck on this device loosing problem - reboot seems to work
^^ I'm investigating these days, when it works I'll load it to github with better docs...

also haven't figured out how to use py asyncio, but using screen with crontab to start both - works also ;) ..
you need to start gpio and Rfspoty side by side
also -> sudo is needed for usb rfid, can't find the right stuff to change udev rules...

After getting an glimpse overview of why Spotify stopped working, I quit my Premium subscription right away (as this was the only reason to have a subscription in the first place). I cannot imagine that they will revive this API β€” ever. Guess this is expected to happen if you have the monopoly on audio-streaming?!

Has anyone got their box working with providers other than Spotify?

I'll stick with spotify and converted all my stuff to mp3. Slightly more effort but it works even offline.

I switched to MuPiBox and bought touchscreens as adviced... but it only worked one time to play spotify. Now I have a problem.. I hope it will be solved

varac commented

@oswaldo-be Could you please share more of your migration experiences with MuPiBox ? Given the time frame of a possible fix for Phoniebox I guess it's a viable alternative to many of us, as sad as it is.

After getting an glimpse overview of why Spotify stopped working, I quit my Premium subscription right away (as this was the only reason to have a subscription in the first place). I cannot imagine that they will revive this API β€” ever. Guess this is expected to happen if you have the monopoly on audio-streaming?!

Has anyone got their box working with providers other than Spotify?

In our new version 3 we use a different implementation of the Spotify API, but the branch future3/spotify is not ready for production yet, see #1815 (comment)

I'll stick with spotify and converted all my stuff to mp3. Slightly more effort but it works even offline.

I did this in the first place, had some connectivity issues. But its realy sad, i hope there will be a alternative too. Maybe with offline playlists? (i hope)

I stuck on this device loosing problem - reboot seems to work ^^ I'm investigating these days, when it works I'll load it to github with better docs...

I've added "sudo systemctl restart raspotify" to cronjob to start every morning and this seems to work... for a couple of days now ;) happy kids

Please follow the discussion about the future of Spotify integration in #1835

As you already all know spotify discontinued libspotify library (see README.md) and lobrespot-java added a disclaimer.

For this very reason, we had to delete the branch future3/spotify, since we are now searching for new solution approaches to integrate spotify API into the future3 phoniebox.

Feel free to propose new ways of integrating supported spotify API into the phoniebox in the discussion forum #1835

I'll stick with spotify and converted all my stuff to mp3. Slightly more effort but it works even offline.

i just did the same and frankly, this wasnt too much work - roughly 2min for each of the 20 cards.
Me - and more importantly my daughter - is happy again.
looking forward to see a new spotify integration, but the immediate pain is gone.

Hi phonieboxers.

I would like to share two solutions/workarounds to satisfy our children until the ultimate Phoniebox release. Neither requires coding or changes to the Phoniebox code.

  • Download albums/playlists as MP3 and move them to the phoniebox SD-card. Onr way to achieve this is using https://github.com/SathyaBhat/spotify-dl/ and following the description there. Note that this tool just downloads metadata from spotify whereas the actual content is downloaded from youtube and therefore potentially different.
  • And the solution I prefer: Delete the premium account of spotify and create one with TIDAL. The look and feel is almost the same as with spotify and works for all of my setups (Sonos integration, android cell phone incl. offline mode and locally on a Windows PC). Moreover, I was able to move my playlists and favorites from Spotify over to Tidal using this service. On the Phoniebox you need to do the following steps:
    1. Install mopidy-tidal according to the Readme. Follow the procedures to for configuration and Oauth authentification (see log files for link and authentificate).
    2. In the Phoniebox webinterface go to Iris (by clicking "Spotify" in the top menu)
    3. You can search for whatever album/playlist you would like to link to an RFID card. Tidal streams should be coming up then! Copy that URL (something like tidal:album:163359476). (Note the link must come from the Iris webinterface, not from the Tidal app!)
    4. Link the card to that URL in the Phoniebox webinterface as you would have done previously with any spotify album/playlist. Create a new folder with a specific name and select "Spotify" as stream type (this is important!).
    5. Done. This should work then. Check the log files of mopidy if you experience issues (journalctl -u mopidy)

Hope this helps you as well!
Best,
rmk

Which tool did you use to convert it?

i used tunefab, 30 day trail with 3min limit per song.
So not really usable for audio books, but fine for songs.

I purchased a 3 months licens for AudFree SpodAble. Costs €15, but does the job quite fast, and writes good MP3 tags, and is also quite fast.

varac commented
* And the solution I prefer: Delete the premium account of spotify and create one with [TIDAL](https://tidal.com). The look and feel is almost the same as with spotify and works for all of my setups (Sonos integration, android cell phone incl. offline mode and locally on a Windows PC). Moreover, I was able to move my playlists and favorites from Spotify over to Tidal using [this service](https://tidal.com/import-playlist). On the Phoniebox you need to do the following steps:
  
  1. Install [mopidy-tidal](https://github.com/tehkillerbee/mopidy-tidal) according to the Readme. Follow the procedures to for [configuration](https://github.com/tehkillerbee/mopidy-tidal) and [Oauth authentification](https://github.com/tehkillerbee/mopidy-tidal) (see log files for link and authentificate).
  2. In the Phoniebox webinterface go to Iris (by clicking "Spotify" in the top menu)
  3. You can search for whatever album/playlist you would like to link to an RFID card. Tidal streams should be coming up then! Copy that URL (something like tidal:album:163359476). (Note the link must come from the Iris webinterface, not from the Tidal app!)
  4. Link the card to that URL in the Phoniebox webinterface as you would have done previously with any spotify album/playlist. Create a new folder with a specific name and select "Spotify" as stream type (this is important!).
  5. Done. This should work then. Check the log files of mopidy if you experience issues (`journalctl -u mopidy`)

@rmk-ch That sounds great! Could you please share what Phoniebox version you use ? I guess it's v2, because I don't see any mopidy in current future3 branch/v3.2.0 release, or am I wrong ?
Is there any chance to easily add mopidy to future3 ?

@rmk-ch

  • Download albums/playlists as MP3 and move them to the phoniebox SD-card. In my opinion the best way to achieve this is using https://github.com/SathyaBhat/spotify-dl/ and following the description there.

I tried spotify_dl without success. Downloading is working well, but the content is not what I initially selected. I loaded some audiobooks and the title/story was the same, but different version / reader.
I then tried to load a single track and it doesn't load the exact content but is just looking for the same title... That's not helpful.
Will try to find another open source tool...
EDIT: I should have read the explenation from the author : "spotify-dl doesn't download anything from Spotify. It picks up the metadata from Spotify API and then uses yt-dlp to download the song."

@varac I am running v2 with spotify enabled.
@passuff ouu i see you're right about this. This is not a spotify download. Sorry for the confusion. Thought it was mich better due zo lower wait times compared to many other tools. I haven't tested this thoroughly due to switching to tidal.

Which tool did you use to convert it?

I can recommend DownOnSpot for this purpose. It is based on librespot and requires a nightly Rust toolchain for building, but overall the process is fairly straightforward. They claim it will also work with a free Spotify account, I did not verify this, but it definitely worked well with my premium account.
Actually now I like this solution more than the streaming version, it is more reliable and Spotify can no longer mess with my custom playlists (which they did a couple of times in the past). Not sure if its covered by their TOS but as long as you have a premium account, it could be argued this falls under fair use.

Hi guys, I just wanted to say a couple of things.

It sucks Spotify have turned libspotify off and they've no interest in supporting projects like this. I assume some of the comments on the Spotify dev forum are from (rightly) unhappy Phoniebox users and although I don't think Spotify will reverse this move, it's still good to demonstrate there is demand for a real libspotify replacement. So thanks to everyone who posted.

Secondly, I am working on a fixed version of Mopidy-Spotify but I don't have much free time so it's sporadic development. And it's a fair bit of work. But progress is being made and I hope to get it working again soon. I can't make any specific timescale promises. I would understand if Phoniebox was to move to another software solution, it's important to find the best fit for your project and get things working for users. But I would hope you avoid projects that circumvent Spotify's Premium subscription requirement as I think that'll just end in everyone losing access. Alternative services like Tidal are an option but they have even worse developer support (it's non-existent). No good options out there, sadly.

I also want to mention it was my colleague that randomly reminded me of Phoniebox when suggesting it as a cool project for me, now I'm a father. Hopefully this explains why dev is slow but at least I've got a vested interest now!

Hi Guys, just wanted to catch up on the last activities since June. What is the actual status? Is there a workaround in place for the libspotify issue?

Many thanks!

283 cards and 2 Phonieboxes deep into this project ... It would be REALLY great if a working release, at least with RFID card reader + working Spotify support, would be released. Even as pre-pre-pre-alpha without any working Web-Interface or anything would be highly appreciated. RFID + Spotify are the only features we use anyways.

Any roadmap there?

Hi, discussion of Spotify feature in Phoniebox should be done in #1835.

As of today there’s no solution yet.

The previously used mopidy-spotify implementation seems to make some progress, but no solution yet:
mopidy/mopidy-spotify#110

Hey all,

while this is not yet a perfect solution I got spotify working again on phoniebox.
The solution is based on the thread referenced by @s-martin.
Major thanks goes to all the contributors in the https://github.com/mopidy/mopidy-spotify/issues/110 thread.

be advised: The solution requires some minor code changes and compilation of one software module , so you should have some basic Linux knowledge to apply the workaround.
I've applied the solution on a Raspberry Pi 4 and slight adjustments might be necessary on older PIs due to the different ARM-architecture.

What did I do to get the solution working:

  1. Download and install a precompiled version of the so-called spotify url handler for gstreamer. This is a specific version of the handler as it was adjusted to be mopidy compliant.
wget https://github.com/mopidy/mopidy-spotify/files/9176522/gst-plugin-spotify_0.9.0_armhf.deb.zip
unzip gst-plugin-spotify_0.9.0_armhf.deb.zip  
sudo dpkg -i gst-plugin-spotify_0.9.0_armhf.deb
sudo ln -s /usr/lib/libgstspotify.so /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgstspotify.so

A restart may be needed to get the plugin working.

  1. Now you should be able to test the gstreamer spotify implementation using the commandline interface:
    gst-launch-1.0 spotifyaudiosrc username=<Username> password=<Password> track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

You need your regular credentials here not any API or application keys.

  1. Download and extract the source code of the mopidy-spotify version created by Kingosticks. Here i used the branch gstspotifysrc-hack. Please be aware this is work in progress and implementation may not be stable yet
wget https://github.com/kingosticks/mopidy-spotify/archive/refs/heads/gstspotifysrc-hack.zip  
unzip gstspotifysrc-hack.zip  
cd mopidy-spotify-gstspotifysrc-hack
  1. Modify the source code you just downloaded to hardcode the credentials
    vi ./mopidy_spotify/backend.py

Almost at the end of the file you will find the following code:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = self.backend._config["spotify"]["username"]
        password = self.backend._config["spotify"]["password"]
        self._auth_string = f"username={username}&password={password}"

I simply replaced the username and password logic with hardcoded values:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = β€œMySpotify@email.com”
        password = β€œMyHardToBreakPassword123!”
        self._auth_string = f"username={username}&password={password}"
  1. Remove the exising installation of mopidy-spotify which is no longer working
    sudo apt-get remove mopidy-spotify

  2. Compile and install the new mopidy-spotify

sudo python3 -m pip install .  

You may need to install pip to execute the compile command.
This can be done via apt:
sudo apt-get install python3-pip

That's it. After applying all this changes I was able to use the spotify feature of the phoniebox again.
Even though there are some limitations right now which may especially affect those of you using phoniebox for Audiobooks.
Currently the implementation only supports Play and Pause you cannot fast forward within a track and you cannot resume a track where you stopped. This hopefully comes at a later stage.

My little boy is very happy now as the PhonieBox is back in action...

I appreciate any feedback if this was helpful and if the approach worked for you as well.

Hey all,

while this is not yet a perfect solution I got spotify working again on phoniebox. The solution is based on the thread referenced by @s-martin. Major thanks goes to all the contributors in the https://github.com/mopidy/mopidy-spotify/issues/110 thread.

be advised: The solution requires some minor code changes and compilation of one software module , so you should have some basic Linux knowledge to apply the workaround. I've applied the solution on a Raspberry Pi 4 and slight adjustments might be necessary on older PIs due to the different ARM-architecture.

What did I do to get the solution working:

  1. Download and install a precompiled version of the so-called spotify url handler for gstreamer. This is a specific version of the handler as it was adjusted to be mopidy compliant.
wget https://github.com/mopidy/mopidy-spotify/files/9176522/gst-plugin-spotify_0.9.0_armhf.deb.zip
unzip gst-plugin-spotify_0.9.0_armhf.deb.zip  
sudo dpkg -i gst-plugin-spotify_0.9.0_armhf.deb
sudo ln -s /usr/lib/libgstspotify.so /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgstspotify.so

A restart may be needed to get the plugin working.

  1. Now you should be able to test the gstreamer spotify implementation using the commandline interface:
    gst-launch-1.0 spotifyaudiosrc username=<Username> password=<Password> track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

You need your regular credentials here not any API or application keys.

  1. Download and extract the source code of the mopidy-spotify version created by Kingosticks. Here i used the branch gstspotifysrc-hack. Please be aware this is work in progress and implementation may not be stable yet
wget https://github.com/kingosticks/mopidy-spotify/archive/refs/heads/gstspotifysrc-hack.zip  
unzip gstspotifysrc-hack.zip  
cd mopidy-spotify-gstspotifysrc-hack
  1. Modify the source code you just downloaded to hardcode the credentials
    vi ./mopidy_spotify/backend.py

Almost at the end of the file you will find the following code:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = self.backend._config["spotify"]["username"]
        password = self.backend._config["spotify"]["password"]
        self._auth_string = f"username={username}&password={password}"

I simply replaced the username and password logic with hardcoded values:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = MySpotify@email.com
        password = MyHardToBreakPassword123!
        self._auth_string = f"username={username}&password={password}"
  1. Remove the exising installation of mopidy-spotify which is no longer working
    sudo apt-get remove mopidy-spotify
  2. Compile and install the new mopidy-spotify
sudo python3 -m pip install .  

You may need to install pip to execute the compile command. This can be done via apt: sudo apt-get install python3-pip

That's it. After applying all this changes I was able to use the spotify feature of the phoniebox again. Even though there are some limitations right now which may especially affect those of you using phoniebox for Audiobooks. Currently the implementation only supports Play and Pause you cannot fast forward within a track and you cannot resume a track where you stopped. This hopefully comes at a later stage.

My little boy is very happy now as the PhonieBox is back in action...

I appreciate any feedback if this was helpful and if the approach worked for you as well.

Thanks for this! Has anyone tried if this works on a pi 3B?

Thanks for this! Has anyone tried if this works on a pi 3B?

Yep. Did this earlier today. Works!

Many thanks for all to all the contributors! :-)

3 additional Points:

  1. I had some porblems cause i used the Spotify User Name and not the E-Mail.

  2. the Email and Password must be in " "

  3. the Spotify password is not allowed to have # in it cause of fstring.

It runs and i hope somebody will find a solution for playing playlists... At the moment there is a long time gab between the songs.

Has anyone tested this for the raspberry zero? My phonieboxes both sadly need the small version.

Also working for me on a raspi 3b on buster. Trying this on some older phoniebox which still runs on stretch sent me directly into the dependency hell. Guess I will need to perform a dist upgrade first.

Thanks to all contributers!

Glad to see the community came up with a workaround.
We will look into it and check, if that can be integrated and how stable it is.

  1. Modify the source code you just downloaded to hardcode the credentials
    vi ./mopidy_spotify/backend.py

Almost at the end of the file you will find the following code:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = self.backend._config["spotify"]["username"]
        password = self.backend._config["spotify"]["password"]
        self._auth_string = f"username={username}&password={password}"

I simply replaced the username and password logic with hardcoded values:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = β€œMySpotify@email.com”
        password = β€œMyHardToBreakPassword123!”
        self._auth_string = f"username={username}&password={password}"

I'm not sure why this is necessary, though.

From my point of view the modified plugin should be able to grab the Spotify credentials from the usual config location. Maybe worth to look into that.

From my point of view the modified plugin should be able to grab the Spotify credentials from the usual config location. Maybe worth to look into that.

Guess I can confirm this, s-martin! I followed the steps of the workaround as described, but still phoniebox was not able to playback from spotify until I changed the credentials in the mopidy conf.

It runs and i hope somebody will find a solution for playing playlists... At the moment there is a long time gab between the songs.

I read about delays before playback starts in the mopidy-spotify issue thread as well. At least for my RPI4 / RPI3B installation I can confirm playback, skip forward and skip back are working without any delay.

From my point of view the modified plugin should be able to grab the Spotify credentials from the usual config location. Maybe worth to look into that.

Would be super if we could get it working like this. I gave it a lot of trial and error attempts to but always ended up with an mopidy error:

error=GLib.Error('Could not get/set settings from/on resource.', 'gst-resource-error-quark', 13) debug='audio/spotify/src/spotifyaudiosrc/imp.rs(280): gstspotify::spotifyaudiosrc::imp (): /GstPlayBin:playbin0/GstURIDecodeBin:uridecodebin0/GstSpotifyAudioSrc:source:\nLogin failed with reason: Bad credentials'

I also spent hours and hours in compiling a new version of gstreamer (1.20) as this is not shipped with buster and build process has a mass of dependencies. Finally I gave the credential overwrite a try and it worked immediatly.
Some of you with more insights on architecture should get into this to find a better approach.

edit: Maybe my issue was even caused by a hash (#) in password. Maybe someone can confirm the password stuff is not required. I just went through all the hassle as it was working using gst-launch-1.0 but not using iris or phoniebox.

A hash in the config file denotes a comment, i.e the text following the hash character is ignored. If I remember correctly, you can avoid that by surrounding your value in quotes:

password = "my#password"

There's no reason this would be different between the old (broken) version of Mopidy-Spotify and this hacked-up workaround version.

For what it's worth, I'm planning to do some more work on the fixed version this week. Not sure if it'll be release ready but I want to sort out seeking and the loading latency.

Works like a charme! Many thanks to @MrStrategy !!!

I just followed the steps, used my "USERNAME"(not Email!) and "Password". I just was able to use the existing Phoniebox installation with all the associated cards, with no issues and no degradation of functions!

The only hint.. I'd like to recommend to be prepared while using part 2:

Now you should be able to test the gstreamer spotify implementation using the commandline interface:
gst-launch-1.0 spotifyaudiosrc username= password= track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

The test went ok, but with FULL volume and basically caused injuries while neighbors were falling out of their bed! ;-)

Cheers!

Modifying the 2nd Phoniebox also turned out to have a problem playing from Spotify until I changed mopidy.conf with the correct authentication credentials!

Guess I can confirm this, s-martin! I followed the steps of the workaround as described, but still phoniebox was not able to playback from spotify until I changed the credentials in the mopidy conf.

If you need to re-authenticate, here is the mopidy authentication link: https://mopidy.com/ext/spotify/#authentication

Location mopidy.conf: /etc/mopidy/mopidy.conf

Just put in your client_id and client_secret, plus username and password and it should work!

Hey all,

while this is not yet a perfect solution I got spotify working again on phoniebox. The solution is based on the thread referenced by @s-martin. Major thanks goes to all the contributors in the https://github.com/mopidy/mopidy-spotify/issues/110 thread.

be advised: The solution requires some minor code changes and compilation of one software module , so you should have some basic Linux knowledge to apply the workaround. I've applied the solution on a Raspberry Pi 4 and slight adjustments might be necessary on older PIs due to the different ARM-architecture.

What did I do to get the solution working:

  1. Download and install a precompiled version of the so-called spotify url handler for gstreamer. This is a specific version of the handler as it was adjusted to be mopidy compliant.
wget https://github.com/mopidy/mopidy-spotify/files/9176522/gst-plugin-spotify_0.9.0_armhf.deb.zip
unzip gst-plugin-spotify_0.9.0_armhf.deb.zip  
sudo dpkg -i gst-plugin-spotify_0.9.0_armhf.deb
sudo ln -s /usr/lib/libgstspotify.so /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgstspotify.so

A restart may be needed to get the plugin working.

  1. Now you should be able to test the gstreamer spotify implementation using the commandline interface:
    gst-launch-1.0 spotifyaudiosrc username=<Username> password=<Password> track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

You need your regular credentials here not any API or application keys.

  1. Download and extract the source code of the mopidy-spotify version created by Kingosticks. Here i used the branch gstspotifysrc-hack. Please be aware this is work in progress and implementation may not be stable yet
wget https://github.com/kingosticks/mopidy-spotify/archive/refs/heads/gstspotifysrc-hack.zip  
unzip gstspotifysrc-hack.zip  
cd mopidy-spotify-gstspotifysrc-hack
  1. Modify the source code you just downloaded to hardcode the credentials
    vi ./mopidy_spotify/backend.py

Almost at the end of the file you will find the following code:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = self.backend._config["spotify"]["username"]
        password = self.backend._config["spotify"]["password"]
        self._auth_string = f"username={username}&password={password}"

I simply replaced the username and password logic with hardcoded values:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        username = β€œMySpotify@email.com”
        password = β€œMyHardToBreakPassword123!”
        self._auth_string = f"username={username}&password={password}"
  1. Remove the exising installation of mopidy-spotify which is no longer working
    sudo apt-get remove mopidy-spotify
  2. Compile and install the new mopidy-spotify
sudo python3 -m pip install .  

You may need to install pip to execute the compile command. This can be done via apt: sudo apt-get install python3-pip

That's it. After applying all this changes I was able to use the spotify feature of the phoniebox again. Even though there are some limitations right now which may especially affect those of you using phoniebox for Audiobooks. Currently the implementation only supports Play and Pause you cannot fast forward within a track and you cannot resume a track where you stopped. This hopefully comes at a later stage.

My little boy is very happy now as the PhonieBox is back in action...

I appreciate any feedback if this was helpful and if the approach worked for you as well.

Wow, thank you very much for that workaround and sharing it here with lots of deperate parents, who had sad kids from the day on their boxes did not work anymore like they used to do.

When I followed your walkthrough, I noticed, that the following section was not in the code anymore:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
username = self.backend._config["spotify"]["username"]
password = self.backend._config["spotify"]["password"]
self._auth_string = f"username={username}&password={password}"


I simply replaced the username and password logic with hardcoded values:

class SpotifyPlaybackProvider(backend.PlaybackProvider):
def init(self, *args, **kwargs):
super().init(*args, **kwargs)
username = β€œMySpotify@email.com”
password = β€œMyHardToBreakPassword123!”
self._auth_string = f"username={username}&password={password}"

I still tried to set it up following the other steps and also updated the mopidy.conf at "/etc/mopidy/mopidy.conf" via new authentication details. It did not work out.

I noticed, that the developer kingosticks has just worked on his project, you are pulling the source code from, and exactly that crucial piece of code changed. With that change, you cannot hardcode the username and password as described in your guide by pulling the newest branch commit.

So in order to follow the procedure of you, which results in a working setup, you need to change step 4 from :

  1. Download and extract the source code of the mopidy-spotify version created by Kingosticks. Here i used the branch gstspotifysrc-hack. Please be aware this is work in progress and implementation may not be stable yet
wget https://github.com/kingosticks/mopidy-spotify/archive/refs/heads/gstspotifysrc-hack.zip  
unzip gstspotifysrc-hack.zip  
cd mopidy-spotify-gstspotifysrc-hack

to

  1. Download and extract the source code of the mopidy-spotify version created by Kingosticks. Here i used the branch gstspotifysrc-hack. Please be aware this is work in progress and implementation may not be stable yet
wget https://github.com/kingosticks/mopidy-spotify/archive/ed98d03e47d3b9c008d7463612124a90af5cf017.zip  
unzip ed98d03e47d3b9c008d7463612124a90af5cf017.zip  
cd mopidy-spotify-ed98d03e47d3b9c008d7463612124a90af5cf017

This will pull the commit that was the leading one, when the workaround guide was published.
With that special commit everything worked like a charm.
So thank you very much!!!

Kind regars
Eric

Hello people,

I have a question about the hack written here by @CallMeErc and @Hamsert.
I can't get the hack to work for me. I can not play Spotify songs or album in Mopidy as well as in Phoniebox.
I can only call it from the command line with gst:

gst-launch-1.0 spotifyaudiosrc username=<Username> password=<Password> track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

Which Mopidy and Phoniebox versions do you use that it works?
And can you play whole albums with gst?
My version is:
Pi 3B
Phoniebox - 2.2 - 305325d - master

thanks a lot

Hello people,

I have a question about the hack written here by @CallMeErc and @Hamsert. I can't get the hack to work for me. I can not play Spotify songs or album in Mopidy as well as in Phoniebox. I can only call it from the command line with gst:

gst-launch-1.0 spotifyaudiosrc username=<Username> password=<Password> track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

Which Mopidy and Phoniebox versions do you use that it works? And can you play whole albums with gst? My version is: Pi 3B Phoniebox - 2.2 - 305325d - master

thanks a lot

for me the above mentioned guide does also not work. i think i have a similar issue like @tulpenwase
i followed the tip from @CallMeErc as well.

Mopidy seems not to run, even after the installation of the new mopidy hack. In Iris, i see the following info-box.
grafik

Maybe an idea for instruction could be:

Oct 09 06:24:47 raspberrypi systemd[1]: Starting Mopidy music server...
Oct 09 06:24:47 raspberrypi systemd[1]: Started Mopidy music server.
Oct 09 06:24:50 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.main Starting Mopidy 3.1.1
Oct 09 06:24:50 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.config Loading config from builtin defaults
Oct 09 06:24:50 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy.conf
Oct 09 06:24:50 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.config Loading config from file:///usr/share/mopidy/conf.d/mopidy-local.conf
Oct 09 06:24:50 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.config Loading config from file:///etc/mopidy/mopidy.conf
Oct 09 06:24:50 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.config Loading config from command line options
Oct 09 06:24:50 raspberrypi mopidy[5233]: ERROR [MainThread] mopidy.internal.log Loading logging config '/etc/mopidy/logging.conf' failed. 'formatters'
Oct 09 06:24:52 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.main Enabled extensions: softwaremixer, http, local, m3u, spotify, stream, iris, file, mpd
Oct 09 06:24:52 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.main Disabled extensions: none
Oct 09 06:24:53 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.commands Starting Mopidy mixer: SoftwareMixer
Oct 09 06:24:53 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.commands Mixer volume set to 30
Oct 09 06:24:53 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.commands Starting Mopidy audio
Oct 09 06:24:53 raspberrypi mopidy[5233]: INFO [MainThread] mopidy.commands Starting Mopidy backends: FileBackend, M3UBackend, StreamBackend, SpotifyBackend, LocalBackend
Oct 09 06:24:53 raspberrypi mopidy[5233]: INFO [Audio-2] mopidy.audio.actor Audio output set to "alsasink"
Oct 09 06:24:53 raspberrypi mopidy[5233]: ERROR [SpotifyBackend-6] mopidy_spotify.web Authorization failed, not attempting Spotify API request. Please get new credentials from https://www.mopidy.com/authenticate and/or restart Mopidy to resolve this problem.
Oct 09 06:24:53 raspberrypi mopidy[5233]: ERROR [SpotifyBackend-6] mopidy_spotify.web OAuth token refresh failed: invalid_client Client not known.
Oct 09 06:24:53 raspberrypi mopidy[5233]: ERROR [SpotifyBackend-6] mopidy_spotify.web Failed to load Spotify user profile

There is ibviously something going on with the authorization
Any Ideas?

I made it work again, many thanks for the instructions @MrStrategy

I solved my own mentioned issue some (see last post) by getting new credentials from mopidy from https://www.mopidy.com/authenticate and entering these credentials in /etc/mopidy/mopidy.conf under spotifysection.

Cheers!

After all the positive feedback I tried the fix from @MrStrategy today but unfortunately my box still isn't playing Spotify content (I installed the version mentioned by @CallMeErc).
All the steps were successful. Is there any log I can provide so you could assist me?
apt list --installed doesn't show a mopidy-spotify, is that normal?
Thanks in advance!

@Hamsert have you tried to re-authenticate? I jut had an issue too and it worked for me like this: #1815 (comment)

@Hamsert have you tried to re-authenticate? I jut had an issue too and it worked for me like this: #1815 (comment)

Yes I've tried that, didn't work.

@Hamsert Did the command line test work playing form Spotify? Step 2

@Hamsert Did the command line test work playing form Spotify? Step 2

Yes that worked.

Hey,
while trying to get spotify working i made two observations regarding the sollution posted b @MrStrategy and @CallMeErc
When i first tried to get the test command to run, i got the following error messagen:

WARNING: erroneous pipeline: no element "spotifyaudiosrc"

I figured out that this was caused by the gst-plugin-spotify_0.9.0_armhf.deb package installing the library libgstspotify.so to /usr/lib/ rather than /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/ where at least in my system gstreamer expects its plugins. A symbolic link fixed the issue

After getting this to work i made another observation regarding user authentification: the test command worked, but phoniebox sill did not play anything. I figured out that the mopidy-spotify lib uses the URI handler to command gstreamer and therefore checked the other test command mentioned here https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/tree/main/audio/spotify
gst-launch-1.0 playbin3 uri=spotify:track:3i3P1mGpV9eRlfKccjDjwi?username=$USERNAME\&password=$PASSWORD\&cache-credentials=cache\&cache-files=cache
This failed as well, but i was able to make it run by changing my password to a password without # characters. These characters seem to be handled incorrect using the URI API.

Hope this may be help some other guys getting spotify back to work on their boxes.

URI parameters must always be urlencoded.

After doing the fix, apt list --installed doesn't show a mopidy-spotify, is that normal?
Unfortunately my Box still isn't working, test command worked. Is there anything I can provide so you could assist me?
Thanks in advance!

My Suggestion: Use Version 2 with DownOnSpot to download mp3s until there is a reliable fix available... but i doubt this will be soon

ip0p commented

After doing the fix, apt list --installed doesn't show a mopidy-spotify, is that normal? Unfortunately my Box still isn't working, test command worked. Is there anything I can provide so you could assist me? Thanks in advance!

I also have no mopidy spotify in this list. Maybe its because of the manual install via pip? Can you check if mopidy is running in the phoniebox info? For me it seems I have to start it by hand. And when its started everything works. But I'm still investigating.

After doing the fix, apt list --installed doesn't show a mopidy-spotify, is that normal? Unfortunately my Box still isn't working, test command worked. Is there anything I can provide so you could assist me? Thanks in advance!

I also have no mopidy spotify in this list. Maybe its because of the manual install via pip? Can you check if mopidy is running in the phoniebox info? For me it seems I have to start it by hand. And when its started everything works. But I'm still investigating.

Can you please explain me how to check it it is running and how to start it?

Thanks in advance.

I'm running an older Version of the Phoniebox set up 2020
Version2.0 rc7
EditionPlus Edition (feat. Spotify Integration)
on
Raspbian GNU/Linux 10 (buster)
Release10

SInce then, I (and my kids) were happy with a working phoniebox with spotify.
Up until this bad day...
I am kind of new to all this Pi and GitHub and was happy not to touch the running system.

However, I followed the suggested fix.
When I came to step
sudo apt-get remove mopidy-spotify
I got:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'mopidy-spotify' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.

Nevertheless, I continued with the
sudo python3 -m pip install .
which did something and there was no error.

Unfortunatly, it is not working.
on my dir /home/pi
I find 2 mopidy-spotify folders:
mopidy-spotify (the old one)
mopidy-spotify-ed98d03e47d3b9c008d7463612124a90af5cf017 (the new one)
I have no idea which one is the "active" one and how I can tell, if the phoniebox uses the right, new one.

sudo systemctl status mopidy
gets me
Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2022-11-01 19:56:36 GMT; 6min ago
Process: 545 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS)
Process: 560 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS)
Main PID: 561 (mopidy)
Tasks: 17 (limit: 2200)
Memory: 54.6M
CGroup: /system.slice/mopidy.service
└─561 /usr/bin/python2 /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Any help would be much appreciated.

ip0p commented

After doing the fix, apt list --installed doesn't show a mopidy-spotify, is that normal? Unfortunately my Box still isn't working, test command worked. Is there anything I can provide so you could assist me? Thanks in advance!

I also have no mopidy spotify in this list. Maybe its because of the manual install via pip? Can you check if mopidy is running in the phoniebox info? For me it seems I have to start it by hand. And when its started everything works. But I'm still investigating.

Can you please explain me how to check it it is running and how to start it?

Thanks in advance.

you can see it in the info section on the phoniebox web intercace or type

sudo service mopidy status

if its not running type

sudo dpkg-reconfigure mopidy

and chose yes to make sure its running at start (for me it was the problem it somehow didnt start automatically anymore)
then reboot

ip0p commented

I'm running an older Version of the Phoniebox set up 2020 Version2.0 rc7 EditionPlus Edition (feat. Spotify Integration) on Raspbian GNU/Linux 10 (buster) Release10

SInce then, I (and my kids) were happy with a working phoniebox with spotify. Up until this bad day... I am kind of new to all this Pi and GitHub and was happy not to touch the running system.

However, I followed the suggested fix. When I came to step sudo apt-get remove mopidy-spotify I got: Reading package lists... Done Building dependency tree Reading state information... Done Package 'mopidy-spotify' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.

Nevertheless, I continued with the sudo python3 -m pip install . which did something and there was no error.

Unfortunatly, it is not working. on my dir /home/pi I find 2 mopidy-spotify folders: mopidy-spotify (the old one) mopidy-spotify-ed98d03e47d3b9c008d7463612124a90af5cf017 (the new one) I have no idea which one is the "active" one and how I can tell, if the phoniebox uses the right, new one.

sudo systemctl status mopidy gets me Loaded: loaded (/lib/systemd/system/mopidy.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-11-01 19:56:36 GMT; 6min ago Process: 545 ExecStartPre=/bin/mkdir -p /var/cache/mopidy (code=exited, status=0/SUCCESS) Process: 560 ExecStartPre=/bin/chown mopidy:audio /var/cache/mopidy (code=exited, status=0/SUCCESS) Main PID: 561 (mopidy) Tasks: 17 (limit: 2200) Memory: 54.6M CGroup: /system.slice/mopidy.service └─561 /usr/bin/python2 /usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf

Any help would be much appreciated.

I have no idea what is wrong at your end. The test command does work and play the music?
In your log I see mopidy is running on python2. Maybe you need to use python2 also in the pip install command.
But this is just a thought I'm not really deep into python stuff.

Has anyone tested this for the raspberry zero? My phonieboxes both sadly need the small version.

Didn't work for me on raspberrypiZero. I have the Raspberry Pi Zero W Rev 1.1.

After downloading and installing the gstreamer-plugin from

https://github.com/mopidy/mopidy-spotify/files/9176522/gst-plugin-spotify_0.9.0_armhf.deb.zip
it is blacklisted by gstreamer.

Does anyone have an idea?

Thanks a lot for everyone that put a lot of work into this project. I wish I would not have to write here but my coding skills are limited.

I tried installing Jukebox 2.3 (because I want to have Spotify included) through the installation command as described the wiki

cd; rm buster-install-*; wget https://raw.githubusercontent.com/MiczFlor/RPi-Jukebox-RFID/master/scripts/installscripts/buster-install-default.sh; chmod +x buster-install-default.sh; ./buster-install-default.sh

Tried it on a clean install of Buster lite on a 3B+ with the workaround described from @CallMeErc but did not have any success and getting problems already at Step 2.

Testing the following command:
gst-launch-1.0 spotifyaudiosrc username=<Username> password=<Password> track=spotify:track:3i3P1mGpV9eRlfKccjDjwi ! oggdemux ! vorbisdec ! audioconvert ! autoaudiosink

Running into the error:
gst-launch-1.0: command not found

which indicates that gstreamer is not installed, right?
when I ran the installation I ran into a lot of mopidy errors, which I was expecting upfront.
I was really looking forward to building a phoniebox, had it on my to-do list for quite some time :(
So sad that the Spotify integration is not working out of the box anymore.
Not a big fan of the screen interface of the Mupibox (which has a working Spotify integration) and was looking for a no screen version with simple buttons instead.

Does anyone have a solution for a fresh install of Jukebox2.3 (or even 3.0) with a working Spotify integration?

It has been silent in this thread for a while. I just want to encourage anyone who is missing the spotify integration to give the manual installation a try, it works for me:

  • Perform the "regular" "one-line-install" of Jukebox 2.* as described in the wiki
  • Uninstall the mopidy-spotify extension that (probably?) was installed, with sudo apt-get remove mopidy-spotify
  • Follow the steps described in the readme of mopidy-spotify to manually build gst-plugins-spotify on your raspberry pi: https://github.com/mopidy/mopidy-spotify#dependencies
    • It may look intimidating, but you just copy-and-paste the commands and it worked for me (finished the build process in something like 30 minutes)
    • I had to perform sudo apt-get update before running the apt install command
    • I only changed one other thing from the steps in the readme: I used the command cargo build --package gst-plugin-spotify --release -j1 , as was recommended in disussions here
  • Install the current master version of mopidy-spotify with sudo python3 -m pip install https://github.com/mopidy/mopidy-spotify/archive/main.zip
  • Configure mopidy with your spotify credentials (should have already happened during the one-line-install, otherwise see here
  • Reboot your raspberry pi
  • (I was tinkering a lot before getting this to work, but hopefully I did not forget any steps)

Now spotify integration seems to work fine on my raspberry pi 3b with raspbian bullseye!

Thanks @jnettels for your nice guide, unfortunately I still ran into some issue. As I always find it easier to follow a complete guide, I decided to create one and post it here. So you don't have to jump between different guides/wikis etc.

1. Raspberry Pi OS Bullseye

Use Bullseye, as this ships with Python 3.9, which is needed to build the mopidy-spotify extension. And manually upgrading Python is just a pain in the ass.

2. Add mopidy GPG key

If you don't add the mopidy GPG key, the Phoniebox installation will throw some errors (which actually may get unnoticed) and you'll probably end up with a broken installation.

sudo mkdir -p /etc/apt/keyrings                                               
sudo wget -q -O /etc/apt/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/bullseye.list
sudo apt update 

Source: https://docs.mopidy.com/en/latest/installation/debian

3. Install Phoniebox

cd; rm buster-install-*; wget https://raw.githubusercontent.com/MiczFlor/RPi-Jukebox-RFID/master/scripts/installscripts/buster-install-default.sh; chmod +x buster-install-default.sh; ./buster-install-default.sh

Source: https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/INSTALL

4. Remove default mopidy installation

sudo apt remove mopidy-spotify

5. Install mopidy-spotify extension

5.1. Install rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Don’t forget to source it (see last line of install output)
source "$HOME/.cargo/env"

5.2. Install GStreamer dependencies

sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gcc pkg-config git

5.3. Install gst-plugins-spotify

git clone --depth 1 https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs
cd gst-plugins-rs
cargo build --package gst-plugin-spotify --release -j1
sudo install -m 644 target/release/libgstspotify.so $(pkg-config --variable=pluginsdir gstreamer-1.0)/

5.4. Verify installation

gst-inspect-1.0 spotify

5.5. Install latest version of mopidy-spotify extension

sudo python3 -m pip install https://github.com/mopidy/mopidy-spotify/archive/master.zip

Source: https://github.com/mopidy/mopidy-spotify#dependencies


Troubleshooting

Check mopidy config/extensions

sudo mopidyctl config

If mopidy-spotify could not be loaded, you'll see this line

WARNING [MainThread] mopidy.config Ignoring config section 'spotify' because no matching extension was found

Display logs for debug

Will display e.g. Spotify authentication issues, so just keep this running while (re)starting mopidy.
journalctl -u mopidy -f

Restart mopidy

Make changes from mopidy.conf take effect.
systemctl restart mopidy

mopidy.conf

You definitely want to use /etc/mopidy/mopidy.conf file. The one inside your users dir is not being used when mopidy runs as a service (which it does here).

Make sure to have the correct credentials set. You absolutely need username, password, client_id and client_secret.
It will look like it is working with client_id and client_secret alone, but won't play any songs (no error in the GUI, just won't work).

Kudos to you, @d4rkd3v1l ! I startet with a fresh, empty SD Card and it works!

After more than a year Spotify is working again! Thanks @d4rkd3v1l for the instructions, should be published somewhere @MiczFlor!

Anyone interested in writing a PR, which integrates these steps in https://github.com/MiczFlor/RPi-Jukebox-RFID/blob/develop/scripts/installscripts/buster-install-default.sh ?

Be aware there are multiple places in this script, which handle Spotify specific stuff.

Awesome, finally it works again! Thank you to everyone involved in this solution. So is this a way of integrating Spotify suitable for the future Phoniebox versions?

Thanks, @d4rkd3v1l ! Unfortunately, https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs is offline at the moment. Is there another source for the plugin e.g. https://github.com/sdroege/gst-plugin-rs or is this something different?
Thanks in advance!

EDIT: Back online!

Everything at https://gitlab.freedesktop.org is down, supposedly for maintenance. Even if you had a copy of gst-plugin-rs, you'd be unable to fetch the dependencies that are also hosted there e.g. https://gitlab.freedesktop.org/gstreamer/gstreamer-rs. Hopefully it'll all be back tomorrow and I'll finally get some RPi-compatable gst-plugin-spotify binaries uploaded this week, it's long overdue.

FYI it's back online.

hmm... Following @d4rkd3v1l method above, on a raspberry PI 4 I had to alter the 5.1 step. Installed Rust was for 64 arm linux version, and I had a 32 PI. After installing the correct version of rust everything else worked.

Starting playback (local files worked). Adding a Spotify track URI worked ... for a day. Today nothing from Spotify seems to work any more. Iris web client never worked actually for playback - it just says 'Mopidy: Failed to add some tracks' when pressing play from it. No error messages in mopidy logs.

I tried to follow @d4rkd3v1l 's guide now 2 times, always starting with a fresh Raspberry Pi OS bullseye image. And I always end up with the same result:

After 5.3. Install gst-plugins-spotify, I am trying to execute gst-inspect-1.0 spotify:

bash: gst-inspect-1.0: command not found

This also does not change after restarting the session, so "fresh" commands are recognized.
I also tried to find the command anywhere:

root@phoniebox-dev:~/gst-plugins-rs# find / -name 'gst-inspect*'
root@phoniebox-dev:~/gst-plugins-rs#

These are the choices I made:

################################################
WIFIconfig=NO
WIFIcountryCode=DE
EXISTINGuse=NO
AUDIOiFace="Headphone"
SPOTinstall="YES"
MPDconfig="YES"
DIRaudioFolders="/root/RPi-Jukebox-RFID/shared/audiofolders"
GPIOconfig="YES"
################################################

The following I noticed along the way:

  1. My "Raspberry Pi 3 Model B Plus Rev 1.3" has 1 GB of RAM. I had to create 2 GB swapfile before compiling gst-plugins-rs succeeded.

  2. Recent Raspberry Pi OS does not come with the user pi by default. You are asked to create any user on the first startup. This renders some things fail (like backing up data on recurring execution) since user pi seems to be used hardcoded.

  3. After the script has finished, apt remove mopidy-spotify shows Package 'mopidy-spotify' is not installed:

    root@raspberrypi:~# apt remove mopidy-spotify
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Package 'mopidy-spotify' is not installed, so not removed
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    root@raspberrypi:~#
    
  4. In the installer script, line 797, there seems to be some Raspberry Pi workaround for kernel packages, which does not "fit" in my Pi 3B:

    [[ aarch64 =~ ^armv.+$ ]]
    
  5. It seems there are some issues while installing mopidy:

    + echo 'Installing dependencies for Spotify support...'
    Installing dependencies for Spotify support...
    + echo -e 'Package: mopidy\nPin: version 3.*\nPin-Priority: 1001'
    + sudo tee /etc/apt/preferences.d/mopidy
    Package: mopidy
    Pin: version 3.*
    Pin-Priority: 1001
    + sudo wget -q -O /usr/local/share/keyrings/mopidy-archive-keyring.gpg https://apt.mopidy.com/mopidy.gpg
    + sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/buster.list
    + sudo apt-get -qq --yes update
    + sudo apt-get -qq --yes upgrade
    + sudo apt-get -qq --yes --allow-downgrades --allow-remove-essential --allow-change-held-packages install mopidy mopidy-mpd mopidy-local mopidy-spotify
    E: Unable to correct problems, you have held broken packages.
    + sudo apt-get -qq --yes --allow-downgrades --allow-remove-essential --allow-change-held-packages install libspotify12 python3-cffi python3-ply python3-pycparser python3-spotify
    E: Unable to correct problems, you have held broken packages.
    + sudo python3 -m pip install --upgrade --force-reinstall -q -r /root/RPi-Jukebox-RFID/requirements-spotify.txt
    + echo 'Installing additional Python packages...'
    

This, as a summary is my 2 times repeated experience with a fresh Raspberry Pi OS bullseye.
Maybe it helps.

Same here!

I have tried on a fresh Bullseye install with a Pi4. After installing with the phoniebox install-script, the mopidy-spotify integration was missing, so there was nothing to remove actually.
I was not able to get it work following the other steps.

Still trying further to get it solved!

I'm currently going through it step by step since it is clear what is failing there and most of it should be easy to fix. Just filed my findings here interim.
I will work through the setup script today and come up with a merge request once done and working.

If someone would review and merge #2063, I would continue with the Spotify/bullseye changes/fixes discussed here, based on that.
Did not want to change too much in a single MR though ...

In the meantime, I looked into the issues further. There are surprisingly few of the workarounds once introduced by the buster-script still required in bullseye - I introduced some changes (in ADDITION to #2063, which is absolutely required on my Raspberry Pi 3B with 1GB RAM) to the buster-* script. Now, it is running for several hours (Rust and GST plugin compile takes a lot of time!) but it is working for me now!

Please Review (and merge) #2064 to fix the issues found.

In the meantime, if you want to test the install on your own before #2063 and #2064 were merged, please follow these steps for testing:

On a freshly installed Raspberry Pi OS bullseye, execute the following script (as user pi, not root):

#!/usr/bin/env bash
sudo apt update
sudo apt install -y locales-all screen mawk

# Start the long-running stuff in a screen session, if we are not in one already
#
# We are in a screen session
if test -n "$STY"; then
    BRANCH="1815_merged_NO_PUSH"
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8

    sudo apt dist-upgrade -y
    sudo apt install -y vim git

    if [ ! -e "${HOME}/.RPi-Jukebox-RFID" ]; then
        git clone -b "${BRANCH}" https://github.com/The-Judge/RPi-Jukebox-RFID.git "${HOME}/.RPi-Jukebox-RFID"
    fi

    echo ""
    echo "#####################################################################################"
    echo ""

    export GIT_BRANCH="develop"
    export LANG=en_US.UTF-8
    export LC_ALL=en_US.UTF-8
    chmod +x "${HOME}/.RPi-Jukebox-RFID/scripts/installscripts/buster-install-default.sh"
    "${HOME}/.RPi-Jukebox-RFID/scripts/installscripts/buster-install-default.sh"
# We are not in a screen session yet
else
    screen -dmS phonieboxSetup
    SCREEN_SESSION="$(screen -ls | grep phonieboxSetup | head -n 1 | awk '{print $1}')"
    screen -S "${SCREEN_SESSION}" -p 0 -X stuff "$(realpath "${0}") $*$(printf \\r)"
    echo ""
    echo "Install script launched in a new screen session (${SCREEN_SESSION})."
    echo "To see the script output, enter setup information and check the"
    echo "execution status, please attach to the scripts screen session by executing:"
    echo ""
    echo "    screen -r ${SCREEN_SESSION}"
    echo ""
fi

Since the Rust and GST plugin compilation takes a LONG TIME (around 3 hours on my Raspberry Pi 3B 1 GB RAM), the scripts starts the setup process in a screen session, so connection disruptions like SSH session disconnects do not cause the process to be interrupted.

Feedback welcome!

Thank you!

I have tried your script and get a permission error:

-bash: /home/pi/.RPi-Jukebox-RFID/scripts/installscripts/buster-install-default.sh: Permission denied

I also could not find the folder:

/home/pi/.RPi-Jukebox-RFID

Thx!
U
PS: I have changed user rights for the /home folder and was able to execute the phoniebox installer now!

Thank you!

I have tried your script and get a permission error:

-bash: /home/pi/.RPi-Jukebox-RFID/scripts/installscripts/buster-install-default.sh: Permission denied

I also could not find the folder:

/home/pi/.RPi-Jukebox-RFID

Thx! U PS: I have changed user rights for the /home folder and was able to execute the phoniebox installer now!

Thx, I added a chmod to my execution instruction before.

The folder you are missing is created by the Git clone.

There's a typo.

Remove the . before RPi

There's a typo.

Remove the . before RPi

No, that's actually on purpose. I do not want that branch to get in conflict with the "real" Repo which is checked out during install. That is why I check the repo out to the "dotted" folder interim-wise, until the Pull Requests are reviewed an merged.