From e412b9bc6b66935638b693fe627d557ea82766bb Mon Sep 17 00:00:00 2001 From: David Gadling Date: Mon, 18 May 2009 15:40:38 -0700 Subject: youtube: fixes for older XML parsers REXML in (at least) Ruby 1.8.6 doesn't support the @attr xpath to get an attribute value. Use the slightly more verbose way of doing it. --- data/rbot/plugins/youtube.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/youtube.rb b/data/rbot/plugins/youtube.rb index 6d3248d9..49d33726 100644 --- a/data/rbot/plugins/youtube.rb +++ b/data/rbot/plugins/youtube.rb @@ -62,11 +62,11 @@ class YouTubePlugin < Plugin :title => (e.elements["media:group/media:title"].text rescue nil), :desc => (e.elements["media:group/media:description"].text rescue nil), :cat => (e.elements["media:group/media:category"].text rescue nil), - :seconds => (e.elements["media:group/yt:duration/@seconds"].value.to_i rescue nil), - :url => (e.elements["media:group/media:player/@url"].value rescue nil), - :rating => (("%s/%s" % [e.elements["gd:rating/@average"].value, e.elements["gd:rating/@max"].value]) rescue nil), - :views => (e.elements["yt:statistics/@viewCount"].value rescue nil), - :faves => (e.elements["yt:statistics/@favoriteCount"].value rescue nil) + :seconds => (e.elements["media:group/yt:duration/"].attributes["seconds"].to_i rescue nil), + :url => (e.elements["media:group/media:player/"].attributes["url"] rescue nil), + :rating => (("%s/%s" % [e.elements["gd:rating"].attributes["average"], e.elements["gd:rating/@max"].value]) rescue nil), + :views => (e.elements["yt:statistics"].attributes["viewCount"] rescue nil), + :faves => (e.elements["yt:statistics"].attributes["favoriteCount"] rescue nil) } if vid[:desc] vid[:desc].gsub!(/\s+/m, " ") @@ -77,12 +77,12 @@ class YouTubePlugin < Plugin vid[:duration] = _("unknown duration") end e.elements.each("media:group/media:content") { |c| - if url = (c.elements["@url"].value rescue nil) - type = c.elements["@type"].value rescue nil - medium = c.elements["@medium"].value rescue nil - expression = c.elements["@expression"].value rescue nil - seconds = c.elements["@duration"].value.to_i rescue nil - fmt = case num_fmt = (c.elements["@yt:format"].value rescue nil) + if url = (c.attributes["url"] rescue nil) + type = c.attributes["type"] rescue nil + medium = c.attributes["medium"] rescue nil + expression = c.attributes["expression"] rescue nil + seconds = c.attributes["duration"].to_i rescue nil + fmt = case num_fmt = (c.attributes["yt:format"] rescue nil) when "1" "h263+amr" when "5" -- cgit v1.2.3