charlie-collard / spotify_cava_colors

Generate colors for cava from the current spotify track
36 stars 1 forks source link

Not getting info from Spotify API #2

Open dcbuild3r opened 5 years ago

dcbuild3r commented 5 years ago

Could you please share an example cava config, because i don't have anything under ~/.config/ named /cava/config . I need the file, otherwise I think it'll work. Thank you for developing this app.

charlie-collard commented 5 years ago

https://github.com/karlstav/cava/blob/master/example_files/config

This is the example config provided by the cava developer

dcbuild3r commented 5 years ago

Well, the thing is even after uncommenting the gradient lines nothing is displayed. I believe to have everything correctly setup as to what regards the Spotify API.

charlie-collard commented 5 years ago

What do you mean when you say nothing is displayed? The terminal running cava is completely empty?

dcbuild3r commented 5 years ago

I suppose that I only have to run spotify_cava_colors, I run it, it seems that it is indeed running the script, however, nothing is happening besides the terminal being occupied

charlie-collard commented 5 years ago

Try running it with the -d flag, that should print some debug output

dcbuild3r commented 5 years ago

It is trying to make requests with the server, maybe it isn't getting the Spotify API right?


``Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Making request to 'https://accounts.spotify.com/api/token'...
Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Making request to 'https://accounts.spotify.com/api/token'...
Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Making request to 'https://accounts.spotify.com/api/token'...
Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
charlie-collard commented 5 years ago

Are you sure the access token credentials you filled in have the correct scope to be able to access your currently playing songs?

dcbuild3r commented 5 years ago

I copied the OAuth stuff from the example app.js they provide I copy pasted that into the files you have in your auth folder + added the client id and secret. Do I need something else?

charlie-collard commented 5 years ago

No that should be enough, I'd delete that image though as this is a public forum and someone could steal the credentials. Just to be safe I'd regenerate them too :P

I've updated the script to log the response from the server, try git pulling and running it again with -d

dcbuild3r commented 5 years ago

Ok, the credentials are cropped, the "..." indicate that. They're like 3 times as long.

dcbuild3r commented 5 years ago

I've made sure to change the credentials in the snippet.

Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Got response: {'error': {'status': 401, 'message': 'Permissions missing'}}
Making request to 'https://accounts.spotify.com/api/token'...
Got response: {'access_token': 'BQDkqSHdjcINdtIbqrE9Ezkx9crQXNmwRK4yGl2Af_M-IGmxleC2ZDSLFjzYqWQt1IYYculjALVDrm4uJIDQs9QMY12313123123123eIYTWcC_Pi5_h0qeiY0wIGQPSPfpjgSCVT9AXHpNJJX1d31OYBFDFDSfsr4M-hCa4QsafR0uaRMx6howHwSHjGQmu', 'token_type': 'Bearer', 'expires_in': 3600, 'scope': 'user-read-email user-read-private'}
Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Got response: {'error': {'status': 401, 'message': 'Permissions missing'}}
Making request to 'https://accounts.spotify.com/api/token'...
Got response: {'access_token': 'BQB-5b9IHH-INz90rPOf24BnUvWqp6Lbd1nVT9Fjp6CH2kmz8m4XuMNDmn81hmqMAUvaCfDmubxCTWEuJHdOoDVEoThFwpkVbVIfHB_IkAS1JrhfrpeqbzLLSH5jHkuxXAoAbeGygmAXGS3DiYikwHvXrewm6uL-yLZSjuVINsp-', 'token_type': 'Bearer', 'expires_in': 3600, 'scope': 'user-read-email user-read-private'}

\

Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Got response: {'error': {'status': 401, 'message': 'Permissions missing'}}
Making request to 'https://accounts.spotify.com/api/token'...
Got response: {'access_token': 'BQAhF-MwWI-4-TsyxAkIJnVDFgpdQo5hoQAgQzwyD4ZigX2fvfFQdOsdsfssdfsdgye12e51sdsg33r2ewcEAFAFEf5252155457eRo1HOTb5rLmSHeB5mgy6SdwGLU9coDVqVMnUajX8NbSa6s4lgutFxghX0s-uVDPqNe1LetZ7mDkQx2dMH4bWZDRM_4ZSj0laNlPLQvKlvZ8ckuqnb', 'token_type': 'Bearer', 'expires_in': 3600, 'scope': 'user-read-email user-read-private'}
Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Got response: {'error': {'status': 401, 'message': 'Permissions missing'}}
Making request to 'https://accounts.spotify.com/api/token'...
Got response: {'access_token': 'BQDMgSeiYjfrrngn41VIhV-bESxKX6q7TgI-TOo-B1L2aaiBLFqkWsd1IfH7nUjCx70sOMc7uyyMfz1ueNYS8rOuD8WGNmA8NTnme1TbmY35NOcCChb7pj_XfBZtciPiqcvG7NnTh8fypeDKaw85ONAycleskhqR5B-jLxcAlDhd', 'token_type': 'Bearer', 'expires_in': 3600, 'scope': 'user-read-email user-read-private'}
Making request to 'https://api.spotify.com/v1/me/player/currently-playing'...
Got response: {'error': {'status': 401, 'message': 'Permissions missing'}}
Making request to 'https://accounts.spotify.com/api/token'...
Got response: {'access_token': 'BQA_SNNubQ9n6_e03SdIS_5XsDH-6Y151CcLnyG7UvRnZ1QvcLzfnur124CsvFtp5XZXHLOCaA-E7UOgPxq2WLG8823c4vYjXnmpTTPK-oM-WTY4VARbzSYm3h-mUDCwBY6cBLFH4AsIknMeq3BjYWWWIy2yPXkMeffOuZBaeRkc', 'token_type': 'Bearer', 'expires_in': 3600, 'scope': 'user-read-email user-read-private'}
charlie-collard commented 5 years ago

Looks like you're missing the required scope(s) https://stackoverflow.com/questions/46348505/spotify-web-api-401-permissions-missing

dcbuild3r commented 5 years ago

I've taken a look at the StackOverflow question, I understand what's at play, but I'm not very familiar with their API nor what logical steps should I take to change the scope. Could you specify what to do, please?

charlie-collard commented 5 years ago

The instructions are pretty detailed here: https://developer.spotify.com/documentation/general/guides/authorization-guide/

Under the Authorization Code Flow heading.

I haven't got time to walk you through the whole thing at the moment, but you start by going to this url (replace your client id here). What you want to get is the refresh token which you can place in the refresh token file in auth.

In your browser go to https://accounts.spotify.com/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&scope=user-read-currently-playing

dcbuild3r commented 5 years ago

Thank you very much for your time and patience it is much appreciated.

dcbuild3r commented 5 years ago

Now I get errors from the script:

Traceback (most recent call last):
  File "/home/autodidactic/bin/spotify_cava_colors", line 145, in <module>
    buckets = bucket_sort(px, 3)
  File "/home/autodidactic/bin/spotify_cava_colors", line 38, in bucket_sort
    for color in [RED, GREEN, BLUE]
  File "/home/autodidactic/bin/spotify_cava_colors", line 38, in <listcomp>
    for color in [RED, GREEN, BLUE]
ValueError: min() arg is an empty sequence
charlie-collard commented 5 years ago

Hmm, try playing a different song on spotify? Sometimes strange artwork (all white or all black) can make it glitch out. I'll try to fix it at some point, I've not used the script in a long time to be honest.

dcbuild3r commented 5 years ago

It seems that the min function is getting no items to compare, the min of 0 items doesn't make sense, therefore it errors on line 179 or so. Notify me if you fix the issue, I'll be watching your repo. I wish you a happy Sunday.