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

Autostart, Clickwheel, Spotify Credentials... How I made the screen work #22

Open
sebakitzing opened this issue Mar 6, 2021 · 27 comments

Comments

@sebakitzing
Copy link

So, I've spent more nights than I should have working on this, my first Raspberry Pi project.

Here are the things I've done following the README file and trying to make it work for myself...

For the ones that don't know, you can code everything from your PC/Mac terminal and you can copy/paste the codes. I didn't know for the first days.

Details on what works and what doesn't at the end of this...

So:

Install Raspberry Pi OS Lite to your Pi and then configure your WiFi on first boot

  1. Install Updates
    sudo apt-get update
    sudo apt-get upgrade

  2. Install Dependencies
    sudo apt install python-setuptools python3-setuptools
    sudo apt install python3-pip
    sudo curl-sL https://dtcooper.github.io/raspotify/install.sh | sh
    sudo apt install install xorg
    sudo apt-get install python3-tk
    sudo apt-get install redis-server
    sudo apt-get install openbox
    sudo apt-get install lightdm
    sudo apt-get install x11-xserver-utils

  3. Install Dependencies
    pip3 install -r requirements.txt
    This command didn't work. So I ran the following:
    sudo apt-get install git
    git clone https://github.com/dupontgu/retro-ipod-spotify-client
    After this:
    cd /home/pi/retro-ipod-spotify-client/frontend/
    To finally run this...
    pip3 install -r requirements.txt

  4. Install pi-btaudio
    git clone https://github.com/bablokb/pi-btaudio.git
    cd pi-btaudio
    sudo tools/install

All worked fine. For bluetooth pairing and instructions, go to https://github.com/bablokb/pi-btaudio

  1. Install PiGPIO
    wget https://github.com/joan2937/pigpio/archive/master.zip
    unzip master.zip
    cd pigpio-master
    make
    sudo make install

I don't know if it works because I haven't been able to use the Clickwheel. Still don't know it it's a hardware or software issue...

  1. Setup Spotify API
    Create a Spotify Developer Account, then create an app where you will get your Client ID, Client Secret, and create a Redirect URI.
    I recommend watching this video and try to make something like the link on README. I think it hasn't worked 100% right for me though...

  2. Disable Screen Blanking
    sudo raspi-config
    Display Option > Screen Blanking > OFF / Disable

  3. Disable Cursor and Screen Savers
    Add or Create and Add this:
    sudo nano /root/.bash_profile
    Then:
    '#!/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

  4. Configure xinitrc
    sudo nano /etc/X11/xinit/xinitrc
    Inside, make sure the following is there:
    #!/bin/sh
    # /etc/X11/xinit/xinitrc
    # global xinitrc file, used by all X sessions started by xinit (startx)
    # invoke global X session script
    #. /etc/X11/Xsession' exec openbox-session #-> This is the one that launches Openbox ;)`

  5. Run "spotifypod.py" with Autostart
    sudo nano /etc/xdg/openbox/autostart
    and add the following command to launch spotifypod.py:
    I made some changes and didn't use the /fork/ folder as in README
    cd /home/pi/retro-ipod-spotify-client/frontend/
    sudo -H -u pi python3 spotifypod.py &
    sudo /home/pi/retro-ipod-spotify-client/clickwheel/click &
    There is no clickso in order to get that:
    cd /home/pi/retro-spotify-client/clickwheel
    gcc -Wall -pthread -o click click.c -lpigpio -lrt
    It returns some warnings but everything is fine. I guess...

  6. Spotify Credentials
    'sudo nano /etc/xdg/openbox/environment'
    Add you credentials:
    export SPOTIPY_CLIENT_ID='your_SPOTIPY_CLIENT_ID'
    export SPOTIPY_CLIENT_SECRET='your_SPOTIPY_CLIENT_SECRET'
    export SPOTIPY_REDIRECT_URI='your_SPOTIPY_REDIRECT_URI'

  7. Syncronize Spotify Data
    Synchronizing Spotify data! Last but not least, if you want to make sure all your playlists artists, etc are synchronized every time you turn on your Spotypod, you can simply modify the script view_model.py
    with the following at line 16:
    #spotify_manager.refresh_devices()
    spotify_manager.refresh_data()

instead of calling refresh_device, you can execute refresh_data. This will sync all your data and then will execute refresh.devices. This will make the boot up way slower! but it will synchronize every single time you switch on :). If you don't run at least once refresh_data() no playlist, artist or anything related with your account will be displayed!

I had errors with this part so I left it as it was...

  1. Configure Raspotify
    sudo nano /etc/default/raspotify
    Uncomment and fill the following line:
    OPTIONS="--username <USERNAME> --password <PASSWORD>"
    And maybe you want also to consider the following:
    # The displayed device type in Spotify clients.
    # Can be "unknown", "computer", "tablet", "smartphone", "speaker", "tv",
    # "avr" (Audio/Video Receiver), "stb" (Set-Top Box), and "audiodongle".
    DEVICE_TYPE="smartphone"

All good. I also changed the Device Name

  1. Display Configuration!
    sudo nano /boot/config.txt
    uncomment (erase #):
    sdtv_mode=2
    comment add (#)
    hdmi_force_hotplug=1
    then add:
    hdmi_ignore_hotplug=1

After this if it throws error for displaying spotifypod.py try the following command:
export DISPLAY=:0.0

So that's what I've got.
The app doesn't autostart. When I start it I get the frontend screen that shows NOW PLAYING when I play a song on my phone. I still haven't been able to work with the clickwheel, it is running with no errors apparently, but it doesn't work with my clickwheel at least so I haven't tried the app on itself.
I connected the Pi to my bluetooth speaker and from my phone I used the Pi as a Remote Device and I got Spotify audio out of it. Is it able to choose it's own songs and play them, I still don't know.
I hope this works for someone and if anybody has any info on how to solve the rest of this, please share hahaha.

Cheers and thanks @dupontgu for this fun project.

@doctorleach
Copy link

I appreciate several of your tweaks, including the need to compile click.c and to use git to clone the dupontgu repository before installing requirements.txt, both of which were necessary.

Since I don't have the cute miniTV yet, I have been running spotifypod.py from the command line, either via ssh with the -Y option or from the Pi ZeroW. However, if I don't comment out the spotify_manager.refresh_data() and refresh_devices() lines, I can't get it to work.

In fact, the Pi boots up into openbox but the spotifypod.py doesn't run (or rather I suspect it fails because of lack of authorization). On the Pi I have to click the mouse to bring up the openbox menu, then choose terminal, then run the python program. The autorun script probably fails because of the environment setting (as best I have been able to tell).

Here's my errors when I allow refresh_data():

python3 spotifypod.py
Traceback (most recent call last):
File "spotifypod.py", line 12, in
from view_model import *
File "/home/pi/retro-ipod-spotify-client/frontend/view_model.py", line 17, in
spotify_manager.refresh_data()
File "/home/pi/retro-ipod-spotify-client/frontend/spotify_manager.py", line 159, in refresh_data
results = sp.current_user_saved_tracks(limit=pageSize, offset=0)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 1183, in current_user_saved_tracks
return self._get("me/tracks", limit=limit, offset=offset)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 291, in _get
return self._internal_call("GET", url, payload, kwargs)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 221, in _internal_call
headers = self._auth_headers()
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/client.py", line 212, in _auth_headers
token = self.auth_manager.get_access_token(as_dict=False)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 481, in get_access_token
"code": code or self.get_auth_response(),
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 436, in get_auth_response
return self._get_auth_response_local_server(redirect_port)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 402, in _get_auth_response_local_server
server = start_local_http_server(redirect_port)
File "/home/pi/.local/lib/python3.7/site-packages/spotipy/oauth2.py", line 1300, in start_local_http_server
server = HTTPServer(("127.0.0.1", port), handler)
File "/usr/lib/python3.7/socketserver.py", line 452, in init
self.server_bind()
File "/usr/lib/python3.7/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
File "/usr/lib/python3.7/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 98] Address already in use

What is working is Spotify generally, as I can connect the Pi to my Bluetooth headphones, use Spotify on my phone to play through the Pi device (which it sees as raspotify), and the menus do come up albeit with the wrong key codes for both my Mac keyboard via ssh and my official Pi keyboard on the Pi.

Have you made any more progress?

@doctorleach
Copy link

I solved my spotifypod.py problem by installing the Midori browser on the Pi (not mentioned in any of the posts I read). Run it first on a Pi 4 to get the .cache file or it will crawl. Just got a breakout board for the click wheel today so I will try the click interface. If that works, the only remaining issue will be getting spotifypod.py to run automatically on boot--I think I have all the settings right, but I will recheck again. And of course I have to locate the cute display which is out of stock everywhere.

@3urobeat
Copy link
Contributor

3urobeat commented Mar 9, 2021

@doctorleach omg thank you so much for posting that, I had no idea what might have caused that error and also prevented the whole UI from loading...

@doctorleach
Copy link

@doctorleach omg thank you so much for posting that, I had no idea what might have caused that error and also prevented the whole UI from loading...

Bitte sehr!

@zburhop
Copy link

zburhop commented Mar 12, 2021

So i think mine is now trying to run. But my screen says "unable to open display" on two lines and then just shows a command prompt. aNY IDEAS?

@doctorleach
Copy link

doctorleach commented Mar 13, 2021

So i think mine is now trying to run. But my screen says "unable to open display" on two lines and then just shows a command prompt. aNY IDEAS?

I see you started another thread about this topic, and assume you have read all the comments there. I'm not sure what is causing your problem, so it would help if you could describe your system. What display are you running on the Pi Zero? Are you using a minidisplay or are you just hooked up to a monitor? Or are you ssh'ing into the Pi?

There is light at the end of the tunnel as I have all the parts working now, including the click wheel. I just bought a smaller NTSC/PAL display from Adafruit because the 2" one is out of stock and not likely to be back in stock for several months. It's slightly too small for the iPod window but it works.

You might also want to look at http://rsflightronics.com/spotifypod, which contains a lot of specific tips.

Here's my setup, which works but isn't yet inside the iPod case:

IMG_0406

@zburhop
Copy link

zburhop commented Mar 13, 2021

I’m running on the pi with the 2”tv screen from adafruit. I did use the tips. It has been booting to a black screen for a couple weeks. I was looking at the area where you type in your Spotify ID and secret I have been adding those within the ‘’ commas. But I started to think that that may be incorrect so I deleted the commas and that when it started booting to the double error and the command prompt.

@doctorleach
Copy link

doctorleach commented Mar 13, 2021

Here are my lines from /etc/X11/openbox/environment:

export SPOTIPY_CLIENT_ID='abcdefg etc'
export SPOTIPY_CLIENT_SECRET='12345 etc'
export SPOTIPY_REDIRECT_URI='http://127.0.0.1:8002'

[note: there is no magic to the port 8002; I just tried several and that was the one I happened to be using when I got my .cache file to work. It needs to be consistent with what you entered in your Spotify administration account as the Redirect URI]

These lines are also in /etc/xdg/openbox/environment for some reason that I either don't know or can't remember.

I also added them to the .bash_profile file in the /home/pi directory and for extra good measure to /root/.bash_profile, but I just looked at the latter file and it has the wrong URI from a previous attempt so it must not be used; ignore it. By the way, the lines need to be preceded by # in the .bash_profile file, as in:
#export SPOTIPY_CLIENT_ID='abcdefg etc'

I could start removing these from each place one at a time to see which ones are really necessary. It took lots of fiddling to get everything to work, as you have discovered.

It seems to me that the spotifypod.py script on your Pi must not be executing or it must be failing. I've partially kept track of my various attempts to get things working but what really did it for me was installing the Midori browser (or any other one). That got me over the Spotify credentials problems I was having because I had no .cache file in the same directory as the spotifypod.py script, and then tweaking the line in the openbox autostart file to read:

sudo -H -u pi --preserve-env=SPOTIPY_REDIRECT_URI,SPOTIPY_CLIENT_ID,SPOTIPY_CLIENT_SECRET python3 spotifypod.py &

seemed to do the trick.

@zburhop
Copy link

zburhop commented Mar 13, 2021

I've done all of that now. The display error is gone but its booting to a black backlit screen again. Not sure what else to try.

@3urobeat
Copy link
Contributor

Having a # before a line just makes it a comment. I have my environmental variables only in the one file specified in the README and it works (but only when starting from the Pi ofc).

What you could try (and what I did too):
Open sudo raspi-config and enable VNC in the interface options. Let it install and connect to the Pi using the VNC Viewer by RealVNC. If you then right click a context menu should appear where you can start a Terminal. This should also appear on your PI's screen if that is working correctly. Then go into the frontend folder and start spitifypod.py and see what output you get. Maybe this helps you getting a different error or at least any error to work with.

I would recommend to disable VNC in the raspi-config again to avoid unnecessary slowdowns when booting. You can always enable the VNC server for one session (so until you shutdown/restart) by typing sudo service vncserver-x11-serviced start.

@doctorleach
Copy link

doctorleach commented Mar 13, 2021

I'm red-faced about my # observations; I should have known that it makes a comment but sometimes when trying to solve a problem I try all sorts of permutations, often without thinking them through. But this demonstrates that my including the Spotipy environment variables in .bash_profile for the user pi is not necessary. So I guess it only needs to be in the file "environment" in the openbox configuration directory in /etc/xdg/openbox/ (I see that /etc/X11/openbox just is a pointer so the environment file only exists in one place, namely /etc/xdg/openbox/environment).

Another suggestion for zburhop is to make sure that the .cache file is present in the same directory as spotifypod.py (presumably the frontend subdirectory). If the spotify_manager.refresh_data() line is not commented out in view_model.py (and maybe the refresh_devices() line would accomplish the same goal), the .cache file gets updated. I suspect it's updated each time these are called, but in any event you could check the date on the .cache file and it should be reasonably close to the current datetime. If it's hours or days older, that probably indicates that the refresh commands are not being executed or not succeeding.

Since you boot to a black screen, it is likely that X11 is starting, but yet another thing to check is that the .bash_profile file for the pi user reads:

#!/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

As of today, the only parts of the project that aren't working well for me are (1) on the Playlists screen, only several of them appear and you can't scroll down to any more than the first few; some bug in the python code? and (2) the screen stays on the whole time, which sucks up a lot of power. I'm using the smaller version of the Adafruit NTSC/PAL screen. The system call os.system('xset -display :0 dpms force off') in spotifypod.py doesn't seem to work, at least not if I try it from the command line, because I get an error message "server does not have extension for dpms option"

@3urobeat
Copy link
Contributor

3urobeat commented Mar 13, 2021

Yeah I do that kinda stuff too from time to time when trying to fix something and then realize afterwards that it didn't make sense at all so no worries :D

The .cache file itself actually only holds the key to authorize an action with Spotify. The data of what has been fetched is stored in a folder called __pycache__ which is also in the frontend directory.
I would once again suggest @zburhop to enable VNC and try out stuff directly on the Pi and therefore in the right environment with it.

For me it was also important to have no other player playing from Spotify while refreshing data as otherwise an error will occurr.

About your playlist bug - try out the changes I made in my pull request #24, maybe that fixes the Playlist problems you are experiencing (it did fix mine!).
I sadly have no idea about the screen sleep problem but I can confirm it turned off the Display output on my Linux Desktop machine while I was experimenting with the code (so it does work but not on the Pi it seems?). And it is also not a perfect solution as it won't turn off the backlight if you are using a different display (like me with a SPI display which has the backlight on when the corresponding GPIO pin is outputting power).

@doctorleach
Copy link

doctorleach commented Mar 13, 2021

@HerrEurobeat -- Well you are right, your pull request #24 fixes the Playlist problem, so the boss should accept your pull request. Und vielen Dank, mein sehr geehrter Herr (are you German? that's how we were taught in German class in the 1960s).

Now I'm down to one problem (assuming I don't break something when I stuff everything in the case), namely getting the display to respond to dpms. I may try your VNC suggestion just to see if I can figure out what happening.

I'm also wiping the cobwebs off my trusty 3D printer to try to make the plastic holding pieces from https://www.thingiverse.com/thing:4789155

@3urobeat
Copy link
Contributor

3urobeat commented Mar 13, 2021

Great to hear that my PR fixes that problem for you too.

Yes I'm German und kein Problem :D

@zburhop
Copy link

zburhop commented Mar 14, 2021

@HerrEurobeat -- Well you are right, your pull request #24 fixes the Playlist problem, so the boss should accept your pull request. Und vielen Dank, mein sehr geehrter Herr (are you German? that's how we were taught in German class in the 1960s).

Now I'm down to one problem (assuming I don't break something when I stuff everything in the case), namely getting the display to respond to dpms. I may try your VNC suggestion just to see if I can figure out what happening.

I'm also wiping the cobwebs off my trusty 3D printer to try to make the plastic holding pieces from https://www.thingiverse.com/thing:4789155

Why go through the trouble with VNC.(just curious) I’m using ssh terminal to talk to the pi already from a windows machine. I never bothered with making this work on a Mac or pc. I just setup the pi with WiFi and ssh from day one and have been trying to work the problem via ssh. Double check what everyone said again tomorrow. Out of curiosity is there a change that someone can make an image file of their working unit sometime. I feel like that would be the easiest way to go as more people inevitably try to build this. An image missing your Spotify credentials obviously lol..... also one bit of confusion for me is how to do the uri address on Spotify. I was just writing http://localhost or whatever at first.

@3urobeat
Copy link
Contributor

3urobeat commented Mar 14, 2021

The idea of using VNC was just to have the exact same environment and "desktop" that you will see on your display.
It helped me a lot to troubleshoot but you can certainly also do everything just through ssh.

This was referenced Mar 15, 2021
@annalynm
Copy link

I've been struggling to get the GUI to render. The .xsession-errors file shows:
"spotipy.oauth2.SpotifyOauthError: No client_id. Pass it or set a SPOTIPY_CLIENT" as the last in a sequence of errors that pertain to the raspotify autorization.

I'm assuming this means the openbox autostart can launch because the account isn't being authorized. I've tried various configurations and URIs to try to get my authorization approved. Does anyone have insight into have to resolve this and/or have a link to an easier guide to API authentication process?

@doctorleach
Copy link

two things to check:

  1. did you tweak the line in the openbox autostart file to read:

sudo -H -u pi --preserve-env=SPOTIPY_REDIRECT_URI,SPOTIPY_CLIENT_ID,SPOTIPY_CLIENT_SECRET python3 spotifypod.py &

  1. did you make an environment file for openbox called /etc/xdg/openbox/environment? The environment variables are set there and need to match the credentials you obtained by creating your own project at developer.spotify.com in the dashboard

@happyfawn
Copy link

Hi guys! I appreciate all ya'lls support on this project. I am so close (at least I hope so, lol) So right now I'm at step 9 and above with OpenBox! Below Ill provide a link to pics of my xinitric, autostart, and openbox path windows.

So far when I try to boot my PI and and open my VNC Viewer it will bring me to my login page where I login and I'm brought to a blank screen. 10 seconds later and I'm brought back to the login window.

I will add that I was confused in the openbox path window and step 12 with syncing my data. I added the 3 "export" commands above the "set system-wide.." and the spotify refresh commands below the "#to set your keyboard.." command. I assume that's where these commands go? I'm not entirely sure TBH.

In step 13 I was confused with "Uncomment and fill the following line:"
Does that mean "delete" something? I didn't see the "#OPTIONS=" command... Maybe I misread what's being said here? Do I have to write that command? With that being being the case, I also couldn't figure out what "uncommenting" meant in step 14.. :(

Well, anywho, I have screenshots of my Openbox windows here: https://drive.google.com/drive/folders/1BQi4NvxVJ_ebSz0gXRTMAb7094VctoYF?usp=sharing

Forgive me, as I am not used to openbox.. lol

Thank you!!
-Jamie

@annalynm
Copy link

I've made some adjustments since my last post and found that there was a problem with the location of one of the files openbox was trying to read. However, I'm still receiving a blank screen with a cursor when I reboot the pi, and the .xsession-errors look like the root of the issue is that my Spoify credentials aren't being authorized.

I've followed all the steps to the best of my knowledge and have tried using
Sudo -H -u pi --preserve-env=SPOTIPY_REDIRECT_URI,SPOTIPY_CLIENT_ID,SPOTIPY_CLIENT_SECRET python3 spotifypod.py &
in my autostart file, which just results in an "unknown user error". Removing it leaves me with just the current error I'm receiving, which is "NameError: 'raw_input' is not defined. (See attached image)

If someone could provide more details on the authorization process for the client credentials, I would appreciate it. I'm pretty sure that's the only thing preventing the software from running at this point.

xsession-errors (03 22 21)

@doctorleach
Copy link

@annalynm I just noticed your post.

So what happens is that the spotifypod.py script is being executed [by the way, this can't be if you removed the sudo -H -u pi line in the autostart file, unless you reinstated the previous version without the --preserve-env flag; and make sure sudo is sudo and not Sudo as it appears in your comment; but I would still recommend the --preserve-env flag]. That script in turn calls view_model.py which in turn calls spotify_manager.py to execute the refresh_data() function. This calls into the spotipy library to get authorization via the oauth2.py script. Here you run into a wall.

Why is this? I'm not sure, but I assume you have a browser installed on the Pi Zero (like Midori?). I've found this can be the most difficult step and the two times I've done the installation I had to fiddle with it quite a bit (as for example changing the port number on the redirect URI--but you have to change it everywhere including on the admin.spotify.com dashboard) and then the damn thing just worked.

Sometimes I think pasting this URL into the browser is what helped create the .cache file in the frontend subdirectory, but I'm not sure; in any event, if you don't have such a .cache file then you haven't been authorized by Spotify yet:

https://accounts.spotify.com/authorize?client_id=XXX&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%20user-library-modify%20user-library-read%20streaming

(replace XXX with client_id and make sure the redirect URI exactly matches the one in your Spotify project setup on spotify.com, although in this browser address box using URL escape codes like %3A for : and %2F for / )

My redirect URI is http://127.0.0.1:8005, but I've tried a few. It seems to work better if you use a port number, but the actual numbers are arbitrary.

@doctorleach
Copy link

Hi guys! I appreciate all ya'lls support on this project. I am so close (at least I hope so, lol) So right now I'm at step 9 and above with OpenBox! Below Ill provide a link to pics of my xinitric, autostart, and openbox path windows.

So far when I try to boot my PI and and open my VNC Viewer it will bring me to my login page where I login and I'm brought to a blank screen. 10 seconds later and I'm brought back to the login window.

I will add that I was confused in the openbox path window and step 12 with syncing my data. I added the 3 "export" commands above the "set system-wide.." and the spotify refresh commands below the "#to set your keyboard.." command. I assume that's where these commands go? I'm not entirely sure TBH.

In step 13 I was confused with "Uncomment and fill the following line:"
Does that mean "delete" something? I didn't see the "#OPTIONS=" command... Maybe I misread what's being said here? Do I have to write that command? With that being being the case, I also couldn't figure out what "uncommenting" meant in step 14.. :(

Well, anywho, I have screenshots of my Openbox windows here: https://drive.google.com/drive/folders/1BQi4NvxVJ_ebSz0gXRTMAb7094VctoYF?usp=sharing

Forgive me, as I am not used to openbox.. lol

Thank you!!
-Jamie

Tried to follow your link to screen shots but google drive says it's in your trash, so I can't see them.

Uncomment means to delete the # character as the start of a line; with the character there the line is ignored / treated as a comment.

@doctorleach
Copy link

@annalynm

Another suggestion is to create a file called testit.py with the following 3 lines:

import spotify_manager
from functools import lru_cache
spotify_manager.refresh_data()

and then run it from the command line:

python3 testit.py

This will only work if you got a .cache file, I think. But if you're good to go you should see output to the screen as it downloads playlists, artists, etc.

@annalynm
Copy link

@doctorleach
Thank you for your response. I did not have a browser installed, but I attempted to install Midori. However, when I attempt to use it to search using this command:
midori -a https://google.com

I get a GtK-WARNING **: cannot open display

I assume I'm suppose to use the midori browser to paste the authorization URL into, per your previous post.
https://accounts.spotify.com/authorize?client_id=XXX&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%20user-library-modify%20user-library-read%20streaming

What am I missing about midori? My .xsession-errors are showing xdg-autostart.vala:64: Not found in OnlyShowIn ,which is a new error. Is this related to the midori problem?

I've also made sure that my CLIENT_ID, CLIENT_SECRET and REDIRECT_URI are the same in all the appropriate locations, but I'm still receiving SpotifyOauthError: No client_id. I'm using https://127.0.0.1:7440/ as my URI. Earlier in the week when I was receiving the No client_id error, I tried numerous different URIs. Do I need to keep trying different ones, or is the issue something else?

I used the testit.py procedure and receive an error for No module named 'spotify_manager'. I assume this confirms the issue is with my spotipy authorization?

This is my first time working with a Raspberrypi, so much of this learning experience is process of elimination (and a lot of what I'm trying to eliminate is my own user error).

Current .xsession-errors
xsession-errors pt 1
xsession-errors pt2

@happyfawn
Copy link

Hi guys! I appreciate all ya'lls support on this project. I am so close (at least I hope so, lol) So right now I'm at step 9 and above with OpenBox! Below Ill provide a link to pics of my xinitric, autostart, and openbox path windows.
So far when I try to boot my PI and and open my VNC Viewer it will bring me to my login page where I login and I'm brought to a blank screen. 10 seconds later and I'm brought back to the login window.
I will add that I was confused in the openbox path window and step 12 with syncing my data. I added the 3 "export" commands above the "set system-wide.." and the spotify refresh commands below the "#to set your keyboard.." command. I assume that's where these commands go? I'm not entirely sure TBH.
In step 13 I was confused with "Uncomment and fill the following line:"
Does that mean "delete" something? I didn't see the "#OPTIONS=" command... Maybe I misread what's being said here? Do I have to write that command? With that being being the case, I also couldn't figure out what "uncommenting" meant in step 14.. :(
Well, anywho, I have screenshots of my Openbox windows here: https://drive.google.com/drive/folders/1BQi4NvxVJ_ebSz0gXRTMAb7094VctoYF?usp=sharing
Forgive me, as I am not used to openbox.. lol
Thank you!!
-Jamie

Tried to follow your link to screen shots but google drive says it's in your trash, so I can't see them.

Uncomment means to delete the # character as the start of a line; with the character there the line is ignored / treated as a comment.

Whoops sorry! Here’s the new link: https://drive.google.com/drive/folders/1mtY5qQvxN93nGYmGw7KHVlXaBoLvyQJi

@theswz
Copy link

theswz commented Apr 24, 2021

@annalynm I'm following your saga as I'm in the same situation right now. Did you figure out anything on your authentication issue? I'm at the point where I don't know why the credentials aren't taking.

@annalynm
Copy link

@theswz I had to temporarily table this project as the peak of the semester hit, so I haven't made much progress since my last post.

The most recent Spotify credential error I received said that the program couldn't the browser to verify the URI.

I connected a mouse to the pi and when it boots to the blank screen with a mouse icon I was able to right click to access a drop down menu and run the midori browser from there. I made a bit of progress trying to get the Spotify credentials to authorize there, but I was struggling because I had to keep alternating between having the keyboard and the mouse plugged in and the pi would reboot if I switched them too many times. (I bought a usb splitter, but I haven't had time to work on the project since then).

The same drop down menu I was running the midori browser from also has a terminal option listed. I've read elsewhere in these forums that some people had more success getting the Spotipy program to run in there.

If you figure it out, please share the secret! I'm hoping to pick the project back up in the next week or so.

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

7 participants