diff --git a/getdistorted/getdistorted.rb b/getdistorted/getdistorted.rb index 99ab97a..5851491 100755 --- a/getdistorted/getdistorted.rb +++ b/getdistorted/getdistorted.rb @@ -42,14 +42,18 @@ # # delete files that aren't in the rss anylonger # "delete" => true, # }, - "pennradio" => { -# "rss" => 'http://www.923freefm.com/pages/podcast/80.rss', - "rss" => 'http://penn.freefm.com/pages/podcast/431.rss', - # %%DATE%% is a magic word here, gets replaced by the pubdate in - # YYYYMMDD format. Won't work if there is no pubDate in the rss feed - "rename" => [ /^/, '%%DATE%%-' ], - "savedir" => '/Users/ward/Private/mp3/[books]/PennRadio', - "linkdir" => '/Users/ward/ipod_sync/[books]/PennRadio', +# "pennradio" => { +# "rss" => 'http://penn.freefm.com/pages/podcast/431.rss', +# # %%DATE%% is a magic word here, gets replaced by the pubdate in +# # YYYYMMDD format. Won't work if there is no pubDate in the rss feed +# "rename" => [ /^/, '%%DATE%%-' ], +# "savedir" => '/Users/ward/Private/mp3/[books]/PennRadio', +# "linkdir" => '/Users/ward/ipod_sync/[books]/PennRadio', +# }, + "bsdtalk" => { + "rss" => 'http://feeds.feedburner.com/Bsdtalk', + "savedir" => '/Users/ward/Private/mp3/[books]/BSDTalk', + "linkdir" => '/Users/ward/ipod_sync/[books]/BSDTalk', }, } @@ -85,11 +89,14 @@ def deleteold(podcast) end def getenclosure(podcast, item) - enclosure = item.get_elements("enclosure")[0] + enclosure = nil + item.each_element{|x| + if x.name == "enclosure" + enclosure = x + end + } pubdate = item.get_elements("pubDate")[0] date = nil - if ! enclosure.nil? - end if ! pubdate.nil? date = Date.parse(pubdate.text).strftime("%Y%m%d") end @@ -131,10 +138,15 @@ for podcast in @podcasts.keys.sort begin res = fetch(@podcasts[podcast]["rss"]) @filelist = {} - + +# body.gsub!(/#{13.chr}#{10.chr}/, "#{10.chr}") xmldoc = REXML::Document.new(res.body) - xmldoc.elements.each("rss/channel/item") {|item| - files.push getenclosure(podcast, item) + xmldoc.elements.each("rss/channel") {|item| + item.each_element{|x| + if x.name == "item" + files.push getenclosure(podcast, x) + end + } } if @podcasts[podcast]["delete"] deleteold(podcast)