One-liner for downloading music files from a Podcast feed, with grep, sed and wget

Premise

I like to listen to music while I code and usually it’s in the form of online radio or a podcast. I believe most portable music players have the ability to sync with podcast feeds nowadays, but I’m an old fashioned guy and sometimes I like to have the music files readily available on my own hard-drive, so I can move them about as I please.

Command

As an example, here is a feed from Tiësto’s club life, on podcast I listen to quite a lot:

http://www.radio538.nl/clublife/podcast.xml

Download it and the run this command:

  grep -E "http.*\.m4a" podcast.xml | sed "s/.*\(http.*\.m4a\).*/\1/" | xargs wget

This is a three step command, that does the following:

  • Extracts all lines, that contains the .m4a file urls using grep.
  • Strips all characters that are not part of the urls.
  • Feeds each line to wget one by one

Ofcourse this is very rudimentary and could easily be transformed into a more general purpose tool in a script. Setting for instance file types via parameter, or even avoiding having to download the feed file first. But this solved the job at hand for me.

Feel free to adapt in any way you please.

Leave a Comment