dns323 podcast downloader

Our server box is taking over lots of little download tasks for us. The next thing I wanted it to do is automatically get podcasts. Being a Ruby fan I knocked up a little script – it’s handy having RSS reading as a core language library!

#!/ffp/bin/env ruby
require 'open-uri'
require 'rss'
IO.readlines(CONFFILE).select{|l| l.strip.size > 0}.each do |feed|
    rss_content = ""
    open(feed) do |f|
        rss_content = f.read
    rss = RSS::Parser.parse(rss_content, false)
    rss.items.each do |item|
            iurl = item.enclosure.url
            ctitle = rss.channel.title.gsub(/\W/, '_')
            system("mkdir -p #{File.join(PODCASTDIR, ctitle)}")
            system("chmod a+rw #{File.join(PODCASTDIR, ctitle)}")
            ifile = File.join(PODCASTDIR, ctitle, File.basename(iurl))
            unless File.exists?(ifile)
            	puts "About to download #{iurl} as #{ifile}"
            	system("wget -O #{ifile} #{iurl}")

All very well, but the server didn’t have Ruby on it. I saw there was a Ruby package in Optware, so I followed the instructions to install Optware and installed the Ruby package.

On testing Ruby I got a message like this:
“can’t load library ‘librt.so.0’”

Fortunately some other people on the forum had encountered this. To resolve it I downloaded their attached librt files and copied them to the /ffp/lib directory.

The next step was to set up a cron job to run the download script. Due to how the dns323 is set up, the recommended way to do this is a startup script which edits the crontab when it runs. This backup script has an example

Unfortunately after doing that, I found my script wasn’t running. It took a few experiments before I realized cron wasn’t setting up all of the PATH I needed. So I wrote a ‘cronhelper’ script to set the PATH and wrap up logging for my cron jobs:

export PATH
echo >> $CRONLOG
echo "*** $mydate" >> $CRONLOG
$* >> $CRONLOG 2>&1

That seemed to do the trick.


  1. jarek
    Posted March 9, 2009 at 11:22 am | Permalink

    Hi, could you explain where to put “cron helper script” – i know little about linux, but would like to use dns323 to download ELT podcasts :)

  2. Edward
    Posted March 10, 2009 at 6:32 am | Permalink

    Ok. Firstly, I have Fonz Fun Plug installed:

    The ruby script from my post is in

    The cronhelper script from my post is in

    Make sure both of those have ‘execute’ permissions.

    The cron line I set up with ‘editcron.sh’ looks like this:
    13 * * * * /ffp/bin/cronhelper /ffp/bin/mypodder.sh

    I hope that helps.

  3. jarek
    Posted March 10, 2009 at 11:55 pm | Permalink

    thank You, it works.
    So, another reason to love the dns-323 ;)
    kind regards,

One Trackback

  1. […] expanded on my previous podcast downloader program so that it gets torrents as well. I was running Automatic but it seemed silly to have two […]

Post a Comment

Your email is never published nor shared. Required fields are marked *