Skip to content

Instantly share code, notes, and snippets.

@electronicbites
Created February 9, 2009 11:13
Show Gist options
  • Save electronicbites/60747 to your computer and use it in GitHub Desktop.
Save electronicbites/60747 to your computer and use it in GitHub Desktop.
gets the tags of a youtube video
require 'rubygems'
require 'hpricot'
require 'net/http'
HOST = "gdata.youtube.com"
SITE = "/feeds/api"
def tags(youtubeid)
request = Net::HTTP::Get.new("#{SITE}/videos?q=#{youtubeid}&safeSearch=none")
request.add_field 'GData-Version', '2'
Net::HTTP.start("#{HOST}", 80) do |http|
entry = Hpricot(http.request(request).body)/'entry'
(entry/'media:keywords').inner_html
end
end
puts tags('001Vzudt-xo')
puts tags('0_0_1xD_T2k')
puts tags('001XYCqJU-Q')
puts tags('00lFrOufbYY')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment