How I fixed Cache, env variables and got everything running
See original GitHub issueJust a few notes on how I got things working, mostly based on what I have read in various issue threads. Credit to #22 #30
/boot/config.txt if you bought the screen from the tutorial
comment out hdmi_force_hotplug=1
#hdmi_force_hotplug=1
uncomment sdtv_mode
sdtv_mode=0
uncomment disable overscan
disable_overscan=1
also want to put in your wpa_supplicant.conf in the boot directory as well at this time
Install git:
Step 2.
Add sudo apt install git
Clone repo
Step 3
add git clone https://github.com/dupontgu/retro-ipod-spotify-client
before installing requirements
add env variables to bash profile
Step 8
sudo nano ~/.bash_profile
#!/bin/bash
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && startx -- -nocursor
# Disable any form of screen saver / screen blanking / power management
xset s off
xset s noblank
export SPOTIPY_CLIENT_ID='your_SPOTIPY_CLIENT_ID'
export SPOTIPY_CLIENT_SECRET='your_SPOTIPY_CLIENT_SECRET'
export SPOTIPY_REDIRECT_URI='http://localhost:8080'
export DISPLAY=:0.0
pass env variables to spotify ipod script
Step 10
replace sudo -H -u pi python3 spotifypod.py &
with sudo -H -u pi --preserve-env=SPOTIPY_REDIRECT_URI,SPOTIPY_CLIENT_ID,SPOTIPY_CLIENT_SECRET python3 spotifypod.py &
Also need to compile click.c
cd /home/pi/retro-spotify-client/clickwheel
gcc -Wall -pthread -o click click.c -lpigpio -lrt
Post install We need to generate a .cache file for the spotify token. I suggest doing this on a pi 3 or 4 and using VNC.
sudo apt install midori
git clone https://github.com/perelin/spotipy_oauth_demo
sudo apt install python python-pip
cd ~/spotipy_oauth_demo
pip install -r requirements.txt
modify spotipy_oauth_demo.py and add your client id and secret
run the oauth demo with python spotipy_oauth_demo.py
using Midori, 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
cp ~/.spotipyautocache ~/retro-ipod-spotify/frontend/.cache
chmod 777 ~/retro-ipod-spotify/frontend/.cache
Run raspi-config
one more time to disable VNC from the interface menu, reboot and now you should be good.
As a side note, be careful with the ipod case being metal it is really easy to short the various solder points you have made. I lined mine with electrical tape to avoid it, in the future I plan on 3d printing something to hold the various components in place and keep them from shorting.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:11 (3 by maintainers)
this totally works and resolves that issue of having first use my iphone or desktop to SELECT the Spotify Connect iPod device with this hardcoding - it goes to the ipod device straight away
thanks
Hi Gents, I figured out what the problem was, because I also had the same issue as NullRunner. In the Browser I always got “INVALID_CLIENT: Invalid redirect URI”. In the spotipy_oauth_demo.py file it says: SPOTIPY_REDIRECT_URI = ‘http://localhost:8080’. You have to use exactly this http://localhost:8080 in your Redirect URIs in the Spotify App.
Then you need to remove the folder /home/pie/.config/midori (rm -rf /home/pie/.config/midori ). This was at least for me important, because the midori browser always showed “INVALID_CLIENT: Invalid redirect URI” due to the fact it was cached.
Other then tomaculum suggested I did not use VNC. I connected the PI zero directly to HDMI and started the midori browser through these two lines in /etc/xdg/openbox/autostart.
sudo vi /etc/xdg/openbox/autostart
python /home/pi/spotipy_oauth_demo/spotipy_oauth_demo.py & midori -e Fullscreen -a http://127.0.0.1:8080
Hope that helps!