Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # SOUNDCLOUD download script by pm74 - probably the shortest you can find in the net!
- # Will not do anything fancy, but just download CURRENT song.
- # DON'T mess around in the browser cache, but take URL from the address bar.
- # Comments to andi3 (AT) gmx (DOT) net
- #!/bin/bash
- # make this script idiot-proof
- # (since some people always feel like putting us to the test if we can code)
- if [[ "$1" == "" ]]; then
- echo "Usage: $0 <URI>"
- exit 1
- fi
- echo "Retrieving file, hang on ... "
- dest=$(wget "$1" -O- -q | grep -o 'streamUrl.*' | cut -f2-3 -d: | cut -f2 -d\" | head -1)
- wget -q -nd --no-use-server-timestamps $dest
- # URL -> filename
- destbase=$(basename $dest)
- if [ -s $destbase ]; then
- echo -e "\nDownloaded $dest to current directory.\n"
- # is this MP3 ?
- if [ "$(file -b --mime-type $destbase)" == "audio/mpeg" ]; then
- # rename mp3 to something (a little) more reasonable
- destfinal=$(cut -f1 -d? <<< $destbase)
- mv $destbase $destfinal.mp3
- echo "File type was identified as 'audio/mpeg' and file renamed to $destfinal.mp3."
- fi
- else
- echo -e "\nERROR: Something went wrong! Please make sure you've typed a valid URI.\n"
- rm -f $destbase
- fi
Add Comment
Please, Sign In to add comment