Boo & DotNetRocks

time to read 2 min | 290 words

Fact: DotNetRocks makes you a better programmer.

Boo makes you a  great programmer.

What happens when you combine them together? The entire dot net rocks archive!

I keep going to the Dot Net Rocks site for more stuff, but because I listen faster than they record (except during the road trip {Hi, when is the next one due :-)}), I've started to dig into their archives. But they are lots of shows, and there doesn't seem to be any torrent for all of the files. After downloading a single show for the tenth time, I decide to put some code into action, instead of clicking on links like an idiot.

Here is the result:

  1. import System.IO
  2. import System.Net
  3. import System.Text.RegularExpressions
  4.  
  5. link_url = """http://perseus\.franklins\.net/[\d\w]+\.mp3"""
  6.  
  7. for i in range(1,157):
  8.         base_url = "http://www.dotnetrocks.com/default.aspx?showID=${i}"
  9.         print "echo Trying to connect to: ${base_url}"
  10.         using response=WebRequest.Create(base_url).GetResponse():              
  11.                 match = Regex(link_url).Match(StreamReader(response.GetResponseStream()).ReadToEnd());
  12.                 print "wget ${match.Value}"
This is just 12 lines of code (with some spaces) to create a script that would download all the shows. You can get wget here and from there, just pipe it to a batch file, and have fun listening.
I really like the way that Boo just stepped out of the way nicely to let me do it.