tychoish, a wiki

tychoish/code/ Boston Sing Downloader

Boston Sing Downloader

I discovered that a singing friend and I had both--independently--written bits of code to download and rename MP3 files that we've been scrapping off of a singing friend's website. So I feel like it's worth sharing to spare others the hassle.

Insert the following into your shell environment, but first:

Good? Ok, here it is:

 boston-sing () {
    mkdir $1
    cd $1
    shift
    wget -nd -r --level=1 --domains=www.bostonsing.org -H $*
    rm index*
    rm robots*
    for i in `ls`
    do
        oldfname=$i
        newfname=`echo $i | sed -r 's/\?.*$//' | sed 's/,//g' | sed 's/+/-/g'`
        if [ ! $oldfname = $newfname ]
        then
            mv $oldfname $newfname
    fi
    done
    cd ../
 }

Then issue a command in the following form:

 $ boston-sing all-california-2011 http://www.bostonsing.org/recordings/all-california-2011/

More abstractly that is:

 $ boston-sing [name of singing/directory] [URL of the page where the links to the singing are]

Enjoy!