Last active
February 15, 2016 15:37
-
-
Save soobrosa/a6119b2ee35555c296f3 to your computer and use it in GitHub Desktop.
Own your list of favourite tracks on Spotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# you need | |
# https://github.com/jehiah/json2csv and | |
# https://stedolan.github.io/jq/ | |
# to roll like this | |
# | |
# get your token at https://developer.spotify.com/web-api/console/get-current-user-saved-tracks/ | |
# | |
token="..." | |
uri="https://api.spotify.com/v1/me/tracks?offset=0&limit=20" | |
while [ "$next" != "null" ]; do | |
buffer=$(curl -s -X GET "$uri" -H "Accept: application/json" -H "Authorization: Bearer $token") | |
echo "$buffer" | jq -c '.items[] | {album_id: .track.album.id, album_name: .track.album.name, artist: .track.artists[0].name, title: .track.name, uri: .track.uri}' | \ | |
json2csv -k album_id,album_name,artist,title,uri | |
uri=$(echo "$buffer" | jq -c '.next' | tr -d '"') | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment