Skip to content

Instantly share code, notes, and snippets.

@Ape
Last active April 17, 2016 09:44
Show Gist options
  • Save Ape/3182b06a35dfa100cdc3b29e6f2b3239 to your computer and use it in GitHub Desktop.
Save Ape/3182b06a35dfa100cdc3b29e6f2b3239 to your computer and use it in GitHub Desktop.
spotifyadd
#!/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