Mastodon

more command line rock

m

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.

About the author

Tom Lee

2 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.

By Tom Lee