My Ruby Cookbook: #2 LugRadio Mirror Add

I have been mirroring the “LugRadio”:http://www.lugradio.org broadcast for a while on my server here. For each new episode, I have to download the new files and then add the urls for those files to their mirror database.

Being that I am lazy and I love ruby (and the php script was ok but Eric.like(:php) == false ), I wrote a “mirror add script”:http://dropbox.www.freelancingdigest.com/bin/lugradio/lugradio-add.rb for myself.

The guts of the script:

#!/usr/bin/env ruby

# Fill in the http url to your files here, no trailing '/'
my_address = "http://lugradio.theadmin.org"

ARGV.each { |file| `wget http://www.lugradio.org/addmirror/#{my_address}/#{file}`}

It will basically use WGET to add in each file you use as an argument. For example I added the latest four by doing

lugradio-add.rb lugradio-s03e06-030106-high.mp3 lugradio-s03e06-030106-low.mp3 \
lugradio-s03e06-030106-high.ogg lugradio-s03e06-030106-low.ogg 

Next I will try to use “NET::HTTP”:http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html goodness to remove the wget dependency and also make one to fetch the current files from rss.

Eric Davis