more command line rock

Recording for posterity, because recreating Perl one-liners is a pain in the ass. If you're on a *nix like system (including OS X), this will download all the MP3s linked from a given URL:

curl -s http://somemusicblog.com/goodsongs.html | perl -nle 'print $1 while /\<a\b[^\>"]*?\bhref=\"?([^\>"]*)\.mp3/g' | xargs -I {} curl -O {}.mp3

UPDATE: This URL might be a good one to try it out on.

Comments

Alternatively, you can do:
"wget -w $SECONDS -r -l2 -A mp3 -H -e robots=off $URL".

The one thing that sucks about that is that it'll build a directory structure for you. If you add "-nd", though, it'll put 'em all in the current directory.

 

Nice, and much simpler. But a lot of the folks reading this will be stuck with curl -- I don't think wget ships with OS X.

 

Post a comment