jlund / spotify-export

A simple Ruby utility that uses Spotify's Web API to export a playlist as plain text
MIT License
293 stars 42 forks source link

maximum spotify api requets #5

Open marianolatorre opened 9 years ago

marianolatorre commented 9 years ago

Hi there, congrats for this tool. its really useful, specially when you want to try all the new streaming services out there.

do you know how many api requets is spotify supporting at the moment? I was able to run it half of my playlist, 4K songs. I was also wondering if the cache you implemented is to avoid requesting again for the already processed tracks? in this case, maybe I can try resuming it tomorrow? oh yeh...do you know after how long its a good time to try again?

cheers!

marianolatorre commented 9 years ago

ok I found the problem, it's to do with the fact that some spotify URLs are pointing to local songs.

/lookup/1/.json?uri=https://open.spotify.com/local/David%20Sylvian%2FRobert%20Fripp/The%20First%20Day/God%27S%20Monkey/297                  |
#<Net::HTTP::Get:0x007f9a2d013ca8>
#<Net::HTTPBadRequest:0x007f9a2d011a70>
A JSON text must at least contain two octets!
marianos-MacBook-Pro:spotify-export marianolatorre$ grep local amazingsongs.txt 
https://open.spotify.com/local/David%20Sylvian%2FRobert%20Fripp/The%20First%20Day/God%27S%20Monkey/297

A possible soultion could be to do the requets and the parsing in different rescue so that when parsing the json fails, we don't keep trying to request after 5 seconds. Another way could be to avoid url containing this "open.spotify.com/local"

jlund commented 9 years ago

At one point this was working for mixed playlists that contained both standard and local songs, but the playlist format for that may have changed. I'll check it out when I get back to a computer.

Thanks for the feedback!

jlund commented 9 years ago

I have never run it on a playlist that large or hit an API limit, so I'm not sure how long they take to timeout. The cache will have saved all of the already processed tracks though, so resuming it should be fast :)

jlund commented 7 years ago

Just looked at this again, and I can't reproduce it. It's a longshot given how much time has passed, but do you have an example of a recent playlist that still exhibits this behavior?