Created
September 6, 2015 05:54
-
-
Save copperwall/9627f209fcb5995d8563 to your computer and use it in GitHub Desktop.
"Stream" songs off soundcloud
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
#!/usr/bin/env bash | |
set -e | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: soundcloud.sh <url>" | |
exit 1 | |
fi | |
RESOLVE_URL="http://api.soundcloud.com/resolve" | |
CLIENT_ID="" | |
LINK="$1" | |
# Give soundcloud link to the resolve endpoint | |
TRACK_INFO=$(curl -sL "$RESOLVE_URL?url=$LINK&client_id=$CLIENT_ID") | |
TITLE=$(jq --raw-output '.title' <<< $TRACK_INFO) | |
USER=$(jq --raw-output '.user.username' <<< $TRACK_INFO) | |
echo | |
echo "Found \"$TITLE\"" | |
echo "By \"$USER\"" | |
echo | |
read -p "Continue? [Y\n] " ANSWER | |
if [ "$ANSWER" = "n" ]; then | |
exit | |
fi | |
echo "downloading..." | |
STREAM_URL=$(jq --raw-output '.stream_url' <<< $TRACK_INFO) | |
echo $STREAM_URL | |
curl "$STREAM_URL?client_id=$CLIENT_ID" -L -o "$TITLE.mp3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment