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.theadmin.org/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

Share

  • Facebook
  • Twitter
  • HackerNews
  • Reddit
  • Tumblr
  • Delicious
  • Email
  • RSS

No related posts.

About Eric Davis

I founded Little Stream Software where I provide Redmine and ChiliProject services to help projects teams. I also created an ebook, Redmine Tips, were I show you how to become more productive using Redmine. I am also the author of Refactoring Redmine, where I go about refactoring Rails using Redmine as an example.

, , , , , ,

Chirk HR     Reuse your existing job applicants »
WP Socializer Aakash Web