SathyaBhat / spotify-dl

Downloads songs from your Spotify Playlist
http://sathyasays.com/2015/12/29/spotify-dl-download-your-spotify-my-music-songs-as-mp3/
MIT License
1.74k stars 213 forks source link

Could not read .cache - loop #111

Closed BimaTh closed 3 years ago

BimaTh commented 3 years ago

So basically I started learning python lately, and found out about this (spotify_dl) I had no issue running at until some point:

it started running using the command that was listed in the readme.md file (spotify_dl -l [link] -o [folder])

It's asking me to set up variables, Why? That will be a good question to answer if possible. Anyways I tried but I didn't manage to set those up. And yes i have An app in Spotify.

Any help please on how to set up Then env variables?

err: ` You need to set your Spotify API credentials. You can do this by setting environment variables like so:

        export SPOTIPY_CLIENT_ID='your-spotify-client-id'
        export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
        export SPOTIPY_REDIRECT_URI='your-app-redirect-url'

        Get your credentials at
            https://developer.spotify.com/my-applications`
SathyaBhat commented 3 years ago

It's asking me to set up variables, Why? That will be a good question to answer if possible.

spotify-dl needs to authenticate with Spotify and get the access token before it can fetch the details. The auth process uses oAuth and as a part of this, the client id, client secret and redirect URIs are required. This is why you set them up. With these values, Spotify will generate an access token that you will have to paste back to complete the auth process.

Any help please on how to set up Then env variables?

err: ` You need to set your Spotify API credentials. You can do this by setting environment variables like so:


        export SPOTIPY_CLIENT_ID='your-spotify-client-id'
        export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret'
        export SPOTIPY_REDIRECT_URI='your-app-redirect-url'

        Get your credentials at
            https://developer.spotify.com/my-applications`

the commands are listed right here

BimaTh commented 3 years ago

Well, I have tried export SPOTIPY_CLIENT_ID='your-spotify-client-id' export SPOTIPY_CLIENT_SECRET='your-spotify-client-secret' export SPOTIPY_REDIRECT_URI='your-app-redirect-url' The 3 of them... Nothing... Getting an Error. tried spotify_dl export SPOTIFY_CLIENT_SECRET='id' still nothing

BimaTh commented 3 years ago

to be more specific, windows couldn't recognize 'export' as in internal or external cmd

SathyaBhat commented 3 years ago

Since you're using Windows, you can use set to export the variables. The getting started guide has link on how to set it up permanently

BimaTh commented 3 years ago

I 've just did this. I made new environment variables, well user variables... not system variables and getting the same issue. i've made everything that was written in the started guide

SathyaBhat commented 3 years ago

You'll need to exit and start a new terminal window or maybe a system restart, for the new environment variables to be shown. You can verify they have been set and available in your terminal by typing

echo %SPOTIPY_REDIRECT_URI%

and this should print the value that was set. If it returns empty then the env variable has not been set.

BimaTh commented 3 years ago

and what if it returned %SPOTIPY_REDIRCT_URL% as a normal echo command?

sorry I know I'm a bit annoying but I'm new to this o.o

SathyaBhat commented 3 years ago

then you typed something wrong

image

BimaTh commented 3 years ago

well, i have changed to the command prompt and it worked! It replied with the value. I don't know why it was reply as an echo back in the new terminal lol. alright. Thanks :) i will try and install a library now

SathyaBhat commented 3 years ago

By new terminal if you mean the Windows Terminal it uses PowerShell which has a different command processor, You can use

dir env:

to see the values.

BimaTh commented 3 years ago

Couldn't write token to cache at: .cache Alright, Moving on I get that now. And it opens the Spotify tab 4 times... Is that normal?

BimaTh commented 3 years ago

well, now that after trying several times:

spotipy.oauth2.SpotifyOauthError: error: invalid_grant, error_description: Authorization code expired
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds`
SathyaBhat commented 3 years ago

It doesn't open any tabs, it prompts you to click on the link to authorize. I dont know why it does for you, there's nothing in the code that prompts opening one tab, let alone multiple.

BimaTh commented 3 years ago

image image

^^^^ and i continue in this loop around 4/5 times and then spotify_dl ends without doing anything

SathyaBhat commented 3 years ago

that seems similar to #108 but I haven't been able to reproduce it. I will take a look when possible

BimaTh commented 3 years ago

I wanted to dowonload my playlist before going to the gym and getting a bug Wow sad Alright, There is anything i can do to help you out? If you wish. i can try reinstalling or telling you how I've installed it, well i have made everything that was in the readme.md file lol

BimaTh commented 3 years ago

if you wish i can try and run it in verbos mode

SathyaBhat commented 3 years ago

Can you try these:

echo %CD%

dir > .test.txt

and tell me the results? I think I found the problem

BimaTh commented 3 years ago

well(i used cmd), okay for the first command echo %CD% it just printed out the dir I'm in, as default C:\Users\accountname

The second command it printed an empty line

BimaTh commented 3 years ago

silence

SathyaBhat commented 3 years ago

Did the second command say

Access is denied.

You can also try

cd Documents

and then issue the spotify_dl command

BimaTh commented 3 years ago

It didn't, it just printed an empty line. Lemme try changing dir to documents and try the Spotify command. and yet nothing....

C:\Users\himoa\Documents>spotify_dl -l https://open.spotify.com/playlist/?si=0R3-dpmzRQaFwFELAhCX7g -o E:\moosicspotify
Starting spotify_dl
Couldn't read cache at: .cache
User authentication requires interaction with your web browser. Once you enter your credentials and give authorization, you will be redirected to a url.  Paste that url you were directed to to complete the authorization.
Opened https://accounts.spotify.com/authorize?client_id=ad050035c64b49e&response_type=code&redirect_uri=https%3A%2F%2Fspotifydl.sathyabh.at%2F&scope=user-library-read in your browser
Enter the URL you were redirected to: https://spotifydl.sathyabh.at/?code=AQALKCGWh7pITcSurAWbbQTNR_h3jfINdatmO4KlLqN6tzXgfp6tFqzI9mHrBnRUo3tIn-AERwPXj89yuSG14GE1HU8N8zx1hwn6B2--eJWVIQx8u8
List ID: 2Gdu0x0YE
List owner: lr6281
List ID: 2Gdu0x0YE
List owner: lr6281xc97q
Saving songs to: PLaying all the time
Traceback (most recent call last):
  File "c:\users\himoa\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\himoa\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\himoa\AppData\Local\Programs\Python\Python39\Scripts\spotify_dl.exe\__main__.py", line 7, in <module>
  File "c:\users\himoa\appdata\local\programs\python\python39\lib\site-packages\spotify_dl\spotify_dl.py", line 116, in spotify_dl
    songs = fetch_tracks(sp, playlist_id, current_user_id)
  File "c:\users\himoa\appdata\local\programs\python\python39\lib\site-packages\spotify_dl\spotify.py", line 28, in fetch_tracks
    for item in results['tracks']['items']:
KeyError: 'tracks'
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-Break to quit

C:\Users\himoa\Documents>

some links have been edited.... where I think it's dangerous to just charge them

SathyaBhat commented 3 years ago

Ok, so we know the original problem. This one is caused by #107 and will be fixed soon, along with your original problem.

BimaTh commented 3 years ago

so umm, is there is any way i can backup to any other version for now until it's fixed? as i said:

I wanted to dowonload my playlist before going to the gym and getting a bug Wow sad

that's in 2 hours, I'm not blaming you. Just wondering any other way I can do that?

SathyaBhat commented 3 years ago

you can try installing the previous version

pip install spotify_dl==5.0.0

and run it from your Documents directory. That should work

BimaTh commented 3 years ago

lemme try, Thanks :)

BimaTh commented 3 years ago
 Searching for CIVIL WAR - Bonus - Russ
Couldn't find id for CIVIL WAR - Bonus - Russ in cache

Is That Normal? o.o

Since it's 130 song so it will take some time But every song i get the same thing couldn't find id

SathyaBhat commented 3 years ago

yes, that is expected. It checks for id in local cache first to reduce time. For first time fetch, it wont be able to find it

BimaTh commented 3 years ago

If you say so... I think I no longer need this conv, at least that's what i think.... Feel free if you wish to close it, if not and you still need to me test with you that would be my pleasure helping in such good app.

Thanks for making such an application :) 👍

BimaTh commented 3 years ago

or not wait xD, image

Any way to skip that?

SathyaBhat commented 3 years ago

You can use the experimental scraper flag to skip API calls, but no guarantees on that

spotify_dl -s -l https://open.spotify.com/playlist/?si=0R3-dpmzRQaFwFELAhCX7g -o E:\moosicspotify
BimaTh commented 3 years ago

let's try

BimaTh commented 3 years ago

E:\moosicspotify>spotify_dl -s -l https://open.spotify.com/playlist/0RkPwjJCAdN7LfUSQtaphh?si=-g02yLOJSlW8A-TbsbiTGg -o E:\moosicspotify usage: spotify_dl [-h] [-d] [-p PLAYLIST] [-V] [-v] [-o OUTPUT] [-u USER_ID] [-i [URI ...]] [-f FORMAT_STR] [-m] [-l URL] [-s SCRAPE] spotify_dl: error: argument -s/--scrape: expected one argument

BimaTh commented 3 years ago

You can use the experimental scraper flag to skip API calls, but no guarantees on that

spotify_dl -s -l https://open.spotify.com/playlist/?si=0R3-dpmzRQaFwFELAhCX7g -o E:\moosicspotify

getting this err

SathyaBhat commented 3 years ago

try

spotify_dl -s true -l https://open.spotify.com/playlist/?si=0R3-dpmzRQaFwFELAhCX7g -o E:\moosicspotify
BimaTh commented 3 years ago
UnboundLocalError: local variable 'playlist_id' referenced before assignment
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds

The error ^ okay that need some test lol

SathyaBhat commented 3 years ago

this has been fixed in latest version. Please upgrade your install using

pip install spotify_dl --upgrade