Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the Project Working with 32bit Bullseye & Raspotify and Zero 2W! #78

Open
doris1347 opened this issue Dec 27, 2024 · 0 comments

Comments

@doris1347
Copy link
Collaborator

doris1347 commented Dec 27, 2024

The project can now work with Legacy Bullseye Lite non desktop version 32bit - Pi Zero 2W

Librespot, and therefore Raspotify, requires a premium account.

I'm using a Raspberry Pi 2W with an Adafruit composite video screen.

Use 32bit Legacy Bullseye Rasberry PiOs Lite (non desktop) and 32bit Latest Raspotify 0.46.1 instead .

Use Redirect URI http://localhost:8080 do not enter your login credentials in sudo nano /etc/raspotify/conf - this will be handled via OAuth #79 method that's built in Latest Raspotify 0.46.1 which has Librespot 6.0 see :

FYI dtcooper/raspotify#675
FYI Using OAuth: Credentials with access token (oauth) librespot-org/librespot#1309 (comment)
FYI dtcooper/raspotify#485

The below will get your "sPoT" working: Pi Zero 2W
Use the Raspberry pi Imager to image the Legacy Bullseye 32bit (non desktop version).
Then - :

sudo apt update && sudo apt upgrade -y

I used most of the issue :
How I got everything working #69 installation procedure

Install the below dependencies one at a time then install Raspotify, Bluetooth, obtain your .cache file, do OAuth (Open Authorization) and finish - - when done continue with whatever you need from #69:

sudo apt install python3-setuptools python3-setuptools -y
sudo apt install python3-pip -y
sudo apt-get install git -y
sudo apt-get install midori
sudo apt-get install python3-pil
sudo apt-get install python3-pil.imagetk
sudo apt-get install realvnc-vnc-server
sudo apt install python-pigpio python3-pigpio
sudo apt-get install python3-tk -y
sudo apt-get install redis-server -y
sudo apt-get install openbox -y
sudo apt install xorg -y
sudo apt-get install lightdm -y
sudo apt-get install x11-xserver-utils -y

git clone https://github.com/dupontgu/retro-ipod-spotify-client

cd retro-ipod-spotify-client/frontend

pip3 install -r requirements.txt

then set redis-server to start on boot, which it does automatically but on some devices it doesn't
sudo systemctl enable redis-server
& do this:
sudo service redis-server start

cd

Do all of the below by following #69 instructions:
Install your Display Screen of choice
Create Developer App.
sudo raspi-config
sudo nano /boot/config.txt
sudo nano .bash_profile
sudo nano /etc/X11/xinit/xinitrc
sudo nano /etc/xdg/openbox/autostart
sudo nano /etc/xdg/openbox/environment
sudo nano /etc/raspotify/conf
sudo nano /etc/asound.conf
Install Pi-btaudio
Install PigPio
Do Clickwheel
cd retro-ipod-spotify-client/clickweel
Compile click.c

gcc -Wall -pthread -o click click.c -lpigpio -lrt

See the below - Pull Request:

FYI https://github.com/dupontgu/retro-ipod-spotify-client/pull/43

click.c fix - Wmain warnings - replace in code Line 160

int main(int argc, char** argv){

and the below - Closed Issue:

FYI https://github.com/dupontgu/retro-ipod-spotify-client/issues/44

High click.c CPU usage replace in code Line 199

while(1) {
sleep(10000);
};
gpioTerminate();
}

If you do the above once again:

Compile click.c

gcc -Wall -pthread -o click click.c -lpigpio -lrt

Use this below latest Raspotify 32bit version:

sudo apt-get -y install curl && curl -sL https://dtcooper.github.io/raspotify/install.sh | sh

sudo systemctl enable raspotify
sudo systemctl restart raspotify

Bluetooth must be up and operational!
Use the below procedure for getting Bluetooth operational under Bullseye:
https://sigmdel.ca/michel/ha/rpi/bluetooth_in_rpios_02_en.html
Do steps 1,2 & 5 only
No need to do the - "sink" part meaning a second Bluetooth® device!
FYI https://stackoverflow.com/questions/70759341/error-in-bluetooth-status-raspberry-pi-failed-to-set-privacy-rejected-0x0

Add your Bluetooth endpoint device MAC Adddress in sudo nano /etc/asound.conf

Be sure in sudo nano /etc/raspotify/conf your device name is correct and exactly the same in your developer app and in:
cd retro-ipod-spotify-client/frontend
nano spotify_manager.py
line 175

No need to add your login credentials in sudo nano /etc/raspotify/conf as long as you have a .cache file in frontend and you did OAuth (Open Authorization)

You must have an authenticated .cache file place it in the frontend folder follow the below procedure to obtain one: spotifypod UI will not open without the .cache file.
git clone https://github.com/perelin/spotipy_oauth_demo
sudo apt install python3 python3-pip
cd ~/spotipy_oauth_demo
pip3 install -r requirements.txt

follow #69
modify spotipy_oauth_demo.py
nano spotipy_oauth_demo.py
and add your client id, secret and redirect uri

add the below scopes:

scope = "user-follow-read," \
        "user-library-read," \
        "user-library-modify," \
        "user-modify-playback-state," \
        "user-read-playback-state," \
        "user-read-currently-playing," \
        "app-remote-control," \
        "playlist-read-private," \
        "playlist-read-collaborative," \
        "playlist-modify-public," \
        "playlist-modify-private," \
        "streaming,"

run the oauth demo with :
python3 spotipy_oauth_demo.py

To use Midori browser comment out #python3 spotifypod.py in sudo nano /etc/xdg/openbox/autostart
and save and reboot ...right click on the black openbox screen then open web browser (will take a while to load) navigate to http://localhost:8080/, you should see a hyperlink that says login to spotify, click it, you will be redirected to spotify login, just login and accept the terms then -

cp ~/spotipy_oauth_demo/.spotipyoauthcache ~/retro-ipod-spotify-client/frontend/.cache
chmod 777 ~/retro-ipod-spotify-client/frontend/.cache

In sudo nano /etc/xdg/openbox/autostart un-comment python3 spotifypod.py save and reboot

If you get an "address already in use" error, just reboot the Pi. Also, as mentioned above the environment variables need to be set, particularly paying attention that the SPOTIPY_REDIRECT_URI matches the redirect URI you entered into your project in developer.spotify.com exactly.

Finally, at least one of the following commands needs to be uncommented--i.e., active--in view_model.py (the second calls the first, so no need for both):

cd retro-ipod-spotify-client/frontend
nano view_model.py
save and exit
follow #69

#spotify_manager.refresh_devices()
 spotify_manager.refresh_data()

sudo reboot

However you may still need to select the device from the spotify-connect list (if you didn't do OAuth (Open Authorization) with your computer/phone first you may have to refresh the Spotify-Connect list a few times to be able to see your "sPoT" device on the list of available devices - you can close immediately after otherwise you will receive "error no devices".

Should you need a device ID:
May or may not be necessary,
You really do not need to obtain, enter and use a device ID however it shouldn't hurt either!
You do need to keep your developer app. device name consistent in sudo nano /etc/raspotify/conf and cd /home/pi/retro-ipod-spotify-client/frontend/
nano spotify_manager.py
Go to line 175 using ctrl+shift+_ and type 175

https://developer.spotify.com/documentation/web-api/reference/get-a-users-available-devices

cd .local/lib/python3.9/site-packages/spotipy/ nano client.py
Line 1795
follow #69 ...

Openbox and Spotifypod.py are opening consistently -Tracks are controllable bluetooth audio operational.

The above procedure tips totally works! works for me too.

Hopefully this project will continue to work with Raspberry PiOs Bookworm and Beyond!

Originally posted by @doris1347 in #74 (comment)

@doris1347 doris1347 changed the title Getting Project Working with Bullseye and Zero 2W! Getting the Project Working with Bullseye and Zero 2W! Dec 27, 2024
@doris1347 doris1347 changed the title Getting the Project Working with Bullseye and Zero 2W! Getting the Project Working with Bullseye 32bit and Zero 2W! Dec 29, 2024
@doris1347 doris1347 changed the title Getting the Project Working with Bullseye 32bit and Zero 2W! Getting the Project Working with 32bit Bullseye & Raspotify and Zero 2W! Dec 29, 2024
@doris1347 doris1347 pinned this issue Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant