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' CONFFILE='/ffp/etc/mypodder.conf' PODCASTDIR='/mnt/HD_a2/podcasts' IO.readlines(CONFFILE).select{|l| l.strip.size > 0}.each do |feed| rss_content = "" open(feed) do |f| rss_content = f.read end rss = RSS::Parser.parse(rss_content, false) rss.items.each do |item| if(item.enclosure) 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}") end end end end
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:
#!/bin/sh PATH=/ffp/sbin:/ffp/bin:/usr/sbin:/sbin:/usr/bin:/bin:/opt/bin export PATH CRONLOG=/mnt/HD_a2/ffp/home/root/cronlog mydate=`date` echo >> $CRONLOG echo "*** $mydate" >> $CRONLOG $* >> $CRONLOG 2>&1
That seemed to do the trick.

3 Comments
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
thanks.
Ok. Firstly, I have Fonz Fun Plug installed:
http://wiki.dns323.info/howto:ffp
The ruby script from my post is in
/ffp/bin/mypodder.rb
The cronhelper script from my post is in
/ffp/bin/cronhelper
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.
thank You, it works.
So, another reason to love the dns-323
kind regards,
Jarek
One Trackback
[…] 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 […]