:default => true,
:desc => "Should the bot display alternative URLs (swf, rstp) for YouTube videos?")
+ def help(plugin, topic="")
+ 'youtube [search] <query> : searches youtube videos | youtube info <id> : returns description and video links'
+ end
+
def youtube_filter(s)
loc = Utils.check_location(s, /youtube\.com/)
return nil unless loc
vids = []
title = nil
begin
+debug s.inspect
doc = REXML::Document.new(s[:text])
title = doc.elements["feed/title"].text
doc.elements.each("*/entry") { |e|
debug id
url = YOUTUBE_VIDEO % {:id => id}
- resp, xml = @bot.httputil.get_response(url)
- unless Net::HTTPSuccess === resp
+ resp = @bot.httputil.get_response(url)
+ xml = resp.body
+ unless resp.kind_of? Net::HTTPSuccess
debug("error looking for movie %{id} on youtube: %{e}" % {:id => id, :e => xml})
return nil
end
what = params[:words].to_s
searchfor = CGI.escape what
url = YOUTUBE_SEARCH % {:words => searchfor}
- resp, xml = @bot.httputil.get_response(url)
- unless Net::HTTPSuccess === resp
+ resp = @bot.httputil.get_response(url)
+ xml = resp.body
+ unless resp.kind_of? Net::HTTPSuccess
m.reply(_("error looking for %{what} on youtube: %{e}") % {:what => what, :e => xml})
return
end
plugin.map "youtube info :movie", :action => 'info', :threaded => true
plugin.map "youtube [search] *words", :action => 'search', :threaded => true
+