Created
February 9, 2009 11:13
-
-
Save electronicbites/60747 to your computer and use it in GitHub Desktop.
gets the tags of a youtube video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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