sigma67 / spotify_to_ytmusic

Clone a Spotify playlist to YouTube Music
MIT License
791 stars 65 forks source link

Transfer Liked songs --> Couldn't read/write token to cache at: .cache #66

Closed eazhar closed 10 months ago

eazhar commented 10 months ago

Hi! Currently trying to transfer my liked songs from Spotify to Youtube Music.

I made a new 'app' on spotify developer with the website and redirect uri set to http://localhost

After running the setup (spotify_to_ytmusic setup), I chose option (3) -- Both. Specified my client ID and client secret from the app on the developer dashboard for Spotify. Then I specified 'yes' for OAuth method for authorization, went to the specified google.com link and linked my account and got the 'Success! Device connected' message on the site.

Afterwards I tried running (spotify_to_ytmusic liked) and it directed me to an https://localhost/?code=AQBAjlzUz2B.... [link truncated]

Which of course could not load on my browser.

The instructions on the terminal indicated pasting the 'URL (I was) redirected to:'

to which I did and it basically opened the same URL in a new browser window with the following message:

Couldn't write token to cache at: .cache
Couldn't read cache at: .cache
Using `localhost` as redirect URI without a port. Specify a port (e.g. `localhost:8080`) to allow automatic retrieval of authentication code instead of having to copy and paste the URL your browser is redirected to.

I also tried switching the URI to localhost:8080 in the Spotify app developer dashboard with no success. What did I miss??

sigma67 commented 10 months ago

Yeah that's a spotipy thing. They were too lazy to code proper paths for the default cache folder, so now you get this random error whenever you run in a Linux home dir with a .cache folder. Their suggestion is to implement a CacheHandler, but I just haven't gotten around to it

eazhar commented 10 months ago

What I ended up doing was creating a public playlist and moved all the songs over to it (ctrl+a and drag/drop on the Spotify client software).

I ran spotify_to_ytmusic create https://open.spotify.com/playlist/...

After that, it would do the same issue, however, I found that it could load up to 100 songs at a time and I just kept copying and pasting the new link it was redirecting me at. A few examples:

Iteration 1

Couldn't write token to cache at: .cache
Spotify tracks: 100/534
Couldn't read cache at: .cache
Using `localhost` as redirect URI without a port. Specify a port (e.g. `localhost:8080`) to allow automatic retrieval of authentication code instead of having to copy and paste the URL your browser is redirected to.
Enter the URL you were redirected to: https://localhost/?code=AQD8o4...

Iteration 2

Couldn't write token to cache at: .cache
Spotify tracks: 200/534
Couldn't read cache at: .cache
Using `localhost` as redirect URI without a port. Specify a port (e.g. `localhost:8080`) to allow automatic retrieval of authentication code instead of having to copy and paste the URL your browser is redirected to.
Enter the URL you were redirected to: https://localhost/?code=AQAyp...

and after repeating this process 6 times total, it worked and my playlist was generated as a new playlist in YouTube music. Hope this helps someone in the future!