summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-24 22:28:30 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-03-24 22:28:30 +0100
commit00e94aa9b086bdbc021095bff2d53ba2617b03e9 (patch)
treeb6c4ba67888c100d3c8a970ff61a998af9c9b41c /data
parenta70a0879fe06aaa9c45cacc04a34e64185e5168b (diff)
youtube plugin: retrieve alternative formats for videos
Diffstat (limited to 'data')
-rw-r--r--data/rbot/plugins/youtube.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/data/rbot/plugins/youtube.rb b/data/rbot/plugins/youtube.rb
index 8868b4b9..1faa7c35 100644
--- a/data/rbot/plugins/youtube.rb
+++ b/data/rbot/plugins/youtube.rb
@@ -53,6 +53,7 @@ class YouTubePlugin < Plugin
# :title => mg["media:title"].text
# fails because "media:title" is not an Integer. Bah
vid = {
+ :formats => [],
:author => (e.elements["author/name"].text rescue nil),
:title => (e.elements["media:group/media:title"].text rescue nil),
:desc => (e.elements["media:group/media:description"].text rescue nil),
@@ -79,6 +80,33 @@ class YouTubePlugin < Plugin
else
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
+ duration = c.elements["@duration"].value rescue nil
+ fmt = case num_fmt = (c.elements["@yt:format"].value rescue nil)
+ when "1"
+ "h263+amr"
+ when "5"
+ "swf"
+ when "6"
+ "mp4+aac"
+ when nil
+ nil
+ else
+ num_fmt
+ end
+ vid[:formats] << {
+ :url => url, :type => type,
+ :medium => medium, :expression => expression,
+ :duration => duration,
+ :numeric_format => num_fmt,
+ :format => fmt
+ }.delete_if { |k, v| v.nil? }
+ end
+ }
debug vid
return vid
end