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