4 ms·
I think something like this still works with a client id, secret, and a playlist: TOKEN=$(curl --basic --user $ID:$SECRET -X POST -d grant_type=client_crede
by zoltar 6y ago
I think something like this still works with a client id, secret, and a playlist:
TOKEN=$(curl --basic --user $ID:$SECRET -X POST -d grant_type=client_credentials https://accounts.spotify.com/api/token | jq -r .access_token)
curl -H "Authorization: Bearer $TOKEN" https://api.spotify.com/v1/playlists/$PLAYLIST/tracks | tee playlist-$PLAYLIST.json | jq -rc '.items[].track | "\(.artists[0].name) -- \(.name)"' | sort
- hello_asdf 6y agoIt works, but the tracks api is limited to 100 max results, so you have to call it multiple times with offset for larger playlists [1]. [1] https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-playlists-tracks https://developer.spotify.com/documentation/web-api/referenc...
- cortesoft 6y agoMost APIs have page size limits.
- hello_asdf 6y agoYep, I was just noting it for anyone else that tried it and was curious.
- fao_ 6y agoYes, that's pagination :) It should be possible to script that out too.
- hello_asdf 6y agoYep, it is, I was just noting it in case someone was wondering why it was being wonky after trying it out. I already did just to test it out, the results include a 'next' link that you can use :)
- ebb_earl_co 6y agoAt least the TOKEN command was perfect for me, thank you! Instead of passing ID and SECRET, I wrote the values from the Spotify Developer Dashboard to a file like so: $ touch .spotify_credentials && chmod 600 .spotify_credentials then edited .spotify_credentials with client_id:client_secret, then $ curl --basic --user "$(cat .spotify_credentials)" -X POST -d grant_type=client_credentials https://accounts.spotify.com/api/token https://accounts.spotify.com/api/token which was successful
- lambdatronics 6y agoCheck out https://github.com/caseychu/spotify-backup https://github.com/caseychu/spotify-backup I'm a user / minor contributor. It could use some polishing, but it gets the job done (JSON or TSV output). I wonder if it could sidestep Spotify restrictions by not providing an explicit interface for uploading playlists to competing services -- just providing the download portion?