From be13cabfd892b04e8c534ad05a45e1b01d388000 Mon Sep 17 00:00:00 2001 From: Ward Wouts Date: Thu, 10 Aug 2006 11:23:08 +0000 Subject: [PATCH] ook de eerste fetch moet bewaakt worden --- getdistorted/getdistorted.rb | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/getdistorted/getdistorted.rb b/getdistorted/getdistorted.rb index 543cf94..99ab97a 100755 --- a/getdistorted/getdistorted.rb +++ b/getdistorted/getdistorted.rb @@ -128,21 +128,26 @@ end for podcast in @podcasts.keys.sort files = Array.new puts podcast - res = fetch(@podcasts[podcast]["rss"]) - @filelist = {} - - xmldoc = REXML::Document.new(res.body) - xmldoc.elements.each("rss/channel/item") {|item| - files.push getenclosure(podcast, item) - } - if @podcasts[podcast]["delete"] - deleteold(podcast) - end - if @podcasts[podcast]["m3u"] - File.open(@podcasts[podcast]["m3u"], "w"){|f| - files.each{|file| - f.puts file - } + begin + res = fetch(@podcasts[podcast]["rss"]) + @filelist = {} + + xmldoc = REXML::Document.new(res.body) + xmldoc.elements.each("rss/channel/item") {|item| + files.push getenclosure(podcast, item) } + if @podcasts[podcast]["delete"] + deleteold(podcast) + end + if @podcasts[podcast]["m3u"] + File.open(@podcasts[podcast]["m3u"], "w"){|f| + files.each{|file| + f.puts file + } + } + end + rescue + rescue Timeout::Error, Errno::EHOSTUNREACH, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Net::HTTPFatalError + puts " error #{$!} fetching, skipping" end end