question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How I fixed Cache, env variables and got everything running

See original GitHub issue

Just 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:open
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
paulomurraycommented, May 28, 2021

After a quick search in the code, I would guess this is the section, where you could do something like this:

https://github.com/dupontgu/retro-ipod-spotify-client/blob/1c26cc6d4edce46981151bac1c0daa355d763554/frontend/spotify_manager.py#L146

def refresh_devices():
    # results = sp.devices()  
    DATASTORE.clearDevices()
    device = UserDevice("your-device-id", "your-device-name", True)            
    DATASTORE.setUserDevice(device)

I’m not sure if you pass a boolean value as is_active parameter and if it really matters.

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

0reactions
henschelmcommented, Oct 11, 2021

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

env file variables are cached · Issue #75 - GitHub
I run react-native run-ios whenever I modify .env file. However, old environment variables are cached and leveraged again.
Read more >
Always have to clear cache in .env? - Stack Overflow
Check APP_ENV in your .env file. If it's on production then yes, laravel caching it. You should run these commands before changing configs:...
Read more >
.env Not Reading Variables Sometimes - Laracasts
I had trouble with config:cache , when it is run, the app (Laravel 5.2) doesn't read files from the .env -file. I ran...
Read more >
Build Environment - Gradle User Manual
caching =true that are typically stored in a gradle.properties file in a project directory or in the GRADLE_USER_HOME . Environment variables such as...
Read more >
Cloud flow not using current value of environment variable at ...
After updating the Environment variable's Current value, go to the Flow which is having the variable > Click on Edit > Click on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found