Last active
April 17, 2016 09:44
-
-
Save Ape/3182b06a35dfa100cdc3b29e6f2b3239 to your computer and use it in GitHub Desktop.
spotifyadd
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/sh | |
set -e | |
TRACK_ID="$1" | |
CLIENT_ID="..." | |
CLIENT_SECRET="..." | |
REFRESH_TOKEN="..." | |
ACCESS_TOKEN=$( | |
curl -sS \ | |
-d client_id=$CLIENT_ID \ | |
-d client_secret=$CLIENT_SECRET \ | |
-d grant_type=refresh_token \ | |
-d refresh_token=$REFRESH_TOKEN \ | |
https://accounts.spotify.com/api/token \ | |
| jq -r .access_token \ | |
) | |
RESPONSE=$( | |
curl -sS \ | |
-X PUT "https://api.spotify.com/v1/me/tracks" \ | |
-H "Authorization: Bearer $ACCESS_TOKEN" \ | |
-H "Content-Type: application/json" \ | |
--data "[\"$TRACK_ID\"]" \ | |
) | |
if [[ -n "$RESPONSE" ]]; then | |
echo "$RESPONSE" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment