Open nato2k opened 3 years ago
spotify refresh devices found results: {'devices': []}
when i launch the spotifypod - the devices are either NULL value - meaning that i can navigate the playlists and such but i cannot click on a song - as the DEVICE is EMPTY and simply displays 0 minutes of the song
is there a way to hard code the device ID into the code? if yes, where?
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.
After a quick search in the code, I would guess this is the section, where you could do something like this:
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
Hi! I'm definitely getting closer here! After running "python spotipy_oauth_demo.py", the hyperlink appears and when I click it, it says "INVALID_CLIENT: Invalid redirect URI." Would that be in the OAuth Demo file? Or in my source code? Or in the Spotify Developer tab? Thank you so much for your time!
My first guess would be the Spotify Developer dashboard. Did you enter a callback URI in the application settings?
I guess you can enter whatever you want as long as it fits the requirements of an URI. I did use spotify-iPod://callback
since this is the same scheme I used for my iOS apps.
The link in the readme indicates that http://127.0.0.1
could work as well.
https://accounts.spotify.com/authorize?client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX&response_type=code&redirect_uri=http%3A%2F%2F127.0.0.1&scope=user-read-playback-state%20user-modify-playback-state%20user-read-currently-playing%20app-remote-control%20streaming%20playlist-modify-public%20playlist-modify-private%20playlist-read-private%20playlist-read-collaborative
I am so close! I am stuck on the authentication step. when I click the authenticate button in Midori after signing in, I get lead to a page saying "Midori can't find the page you're looking for". I tried 127.0.0.1, spotify-iPod://callback, and localhost:8080 as URIs, along with changing them to the same thing in the demo.py, and they have all had the same issue. Is this a trial/error sort of thing?
I guess you are even closer as you think (: If I remember correctly, you need to copy the link of this page into your terminal to complete the authentication. There should be a matching promt, which asks you to paste the url
That's what I'm stuck on now I think. There is no prompt in the terminal, and if I paste it in, it doesn't do anything.
You need to do it from X AFIAK. Just right click, open browser and do it that way.
I guess I'm a bit of a novice at Linux, because I don't really know what that means. Here is what I see in VNC Viewer after allowing the program to have access to my spotify
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!
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 requirementsadd env variables to bash profile Step 8
sudo nano ~/.bash_profile
pass env variables to spotify ipod script Step 10 replace
sudo -H -u pi python3 spotifypod.py &
withsudo -H -u pi --preserve-env=SPOTIPY_REDIRECT_URI,SPOTIPY_CLIENT_ID,SPOTIPY_CLIENT_SECRET python3 spotifypod.py &
Also need to compile click.c
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.