From 3fb0aedc9708d4aeb67f32baefcd37c21032d0cf Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 20 Mar 2007 09:48:13 +0000 Subject: rss plugin: 0.9 feeds don't work, so we just patch them to pretend they are actually 1.0 RDF feeds --- data/rbot/plugins/rss.rb | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 69189417..f85ccc13 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -14,15 +14,19 @@ # # License:: MIT license -require 'rss/parser' -require 'rss/1.0' -require 'rss/2.0' -require 'rss/dublincore' -# begin -# require 'rss/dublincore/2.0' -# rescue -# warning "Unable to load RSS libraries, RSS plugin functionality crippled" -# end +# require 'rss/parser' +# require 'rss/1.0' +# require 'rss/2.0' +# require 'rss/dublincore' +# # begin +# # require 'rss/dublincore/2.0' +# # rescue +# # warning "Unable to load RSS libraries, RSS plugin functionality crippled" +# # end +# +# GB: Let's just go for the simple stuff: +# +require 'rss' class ::RssBlob attr_accessor :url @@ -620,6 +624,11 @@ class RSSFeedsPlugin < Plugin report_problem("reading feed #{feed} failed", nil, m) return nil end + # Ok, 0.9 feeds are not supported, maybe because + # Netscape happily removed the DTD. So what we do is just to + # reassign the 0.9 RDFs to 1.0, and hope it goes right. + xml.gsub!("xmlns=\"http://my.netscape.com/rdf/simple/0.9/\"", + "xmlns=\"http://purl.org/rss/1.0/\"") feed.mutex.synchronize do feed.xml = xml end @@ -633,11 +642,12 @@ class RSSFeedsPlugin < Plugin begin ## do validate parse rss = RSS::Parser.parse(xml) - debug "parsed #{feed}" + debug "parsed and validated #{feed}" rescue RSS::InvalidRSSError ## do non validate parse for invalid RSS 1.0 begin rss = RSS::Parser.parse(xml, false) + debug "parsed but not validated #{feed}" rescue RSS::Error => e report_problem("parsing rss stream failed, whoops =(", e, m) return nil -- cgit v1.2.3