I am a podcaster, audio only. The first thing after I wake up every morning is to sync my iPod/iShuffle. Recently, I noticed one of my favorite channels failed in update. Later I figured out the reason is the podcast owner put too many items in their rss feed. Even it was only 66 items, but due to the source is from Singapore, the slow network also kill the podcast sync.
I need to find a way to re-generate their podcast rss feed then.
Start thinking of php, then python, finally I chose Ruby. A few more resources than the other two. The example to parse and generate the regular rss feed using ruby is not hard to find. But, there is only one demo of how to generate itunes feed, which is using a rss lib created by a Japanese guy, 須藤功平(Kouhei Sutou).
My re-generate code looks like this:
# url of original rss feed
source = “http://podcast.overseakids.com/moviecafe/index.xml”
content = “” # raw content of rss feed will be loaded here
# read rss feed
open(source) do |s| content = s.read end
rss = RSS::Parser.parse(content, false)
# start re-genereat the podcast rss feed
feed = RSS::Rss.new(“2.0”)
feed.channel = rss.channel
# only keep the top 5 items, slice the rest of them
feed.channel.items.slice!( 5 ,feed.channel.items.size – 1 )
When I tried to run this code on my DH share host, it failed due to no rss lib installed. I don’t have root rights, then I found another way to install my own Ruby on DH.
One lesson I learn from last night is, after download lastest ruby bin package using wget and the following installation:
I moved the ruby folder into another place I think it’s more appropriate. That extra action almost drove me nuts, I got ‘Unable to find rbconfig.rb’ problem later when I tried to run any ‘setup.rb’ code.
I looked into ruby/lib folder, there are some file with hard code path info in it. So I decided re-do my installation procedure. The problem went away.
To tell which ruby you are running, run: which ruby. What a natural command!