Reputation: 31
I am creating a smartphone/tablet application for our blues club and in order for me to configure the application to play our music, it requires a URL to the streaming audio. I want to stream songs from one of my SoundCloud sets.
How do I find the URL to the audio stream?
Upvotes: 3
Views: 738
Reputation: 33
It's pretty easy to do with a language like Bash. Here is a simple example that prints all of the streaming URL's and titles of the songs in a set:
#!/bin/bash
ORIGINAL_PAGE="$(echo "$1" | sed 's|https|http|')"
SOURCE="$(curl -s "$ORIGINAL_PAGE")"
SONG_URLS="$(echo "$SOURCE" | grep -oE "(uri\":\"/[^/]*/[^/\"]*\"|href=\"/[^/]*/[^/]*/\?size=large\")" | sed 's|/\?size=large||' | tr '=' '"' | cut -d\" -f3 | sed -e "s|^|http://soundcloud.com|" -e 's|$|/?size=medium|')"
if [ -z "$SONG_URLS" ]; then
printf "No songs were found at: $ORIGINAL_PAGE\n"
exit 1
fi
SONG_COUNT=$(echo "$SONG_URLS" | wc -l)
for (( SONG_ID=1; SONG_ID <= SONG_COUNT; SONG_ID+=1 )); do
SONG_URL="$(echo "$SONG_URLS" | sed -n "$SONG_ID"p)"
SET_SONG_PAGE_SOURCE="$(curl -s "$SONG_URL")"
SONG_TITLE="$(echo "$SET_SONG_PAGE_SOURCE" | grep -o "title\":.*\",\"commentable\"" | sed 's|title\":\"||;s|\",\"commentable\"||' | head -1)"
STREAM_URL="$(echo "$SET_SONG_PAGE_SOURCE" | grep -o "http://media.soundcloud.com/stream/[^\"<]*\?stream_token=[^\"<]*" | head -1)"
echo "$STREAM_URL#$SONG_TITLE"
done
I'm not sure if this will help you or not, but maybe it will. Good luck.
Upvotes: 0
Reputation: 163240
There is no URL to your SoundCloud set.
It sounds like you are referring to a normal stream URL, which is usually where you will give it the URL to a SHOUTcast/Icecast/HTTP stream. SoundCloud resources are served up in individual files, and therefore you don't have a single URL to use.
All is not lost however. If you want to integrate your app with SoundCloud, there is an API available. You can find more information about it here: http://developers.soundcloud.com/blog/stream-and-download
Upvotes: 1