Skip to content

Instantly share code, notes, and snippets.

@chebyte
Created November 25, 2010 14:14
Show Gist options
  • Save chebyte/715440 to your computer and use it in GitHub Desktop.
Save chebyte/715440 to your computer and use it in GitHub Desktop.
things that you can do with youtube_it gem
require 'rubygems'
require 'youtube_it'
KEY = "consumer key"
SECRET = "consumer secret"
#with oauth
client = YouTubeIt::OAuthClient.new(:consumer_key => KEY, :consumer_secret => SECRET, :dev_key => "devkey")
client.authorize_from_access("user_token","user_token_secret")
#with user and passwd
client = YouTubeIt::Client.new(:username => "user", :password => "pass", :dev_key => "devkey")
#upload video
client.video_upload(File.open("test.mov"), :title => "test rails",:description => 'cool vid d00d', :category => 'People',:keywords => %w[cool blah test])
#update video
client.video_update("8LXJ7GrCeyw", :title => "test rails",:description => 'cool vid d00d', :category => 'People',:keywords => %w[cool blah test])
#delete video
puts "delete video" if client.video_delete('vIplVAA7ua4')
#get upload token
puts client.upload_token(:title => "test rails",:description => 'cool vid d00d', :category => 'People',:keywords => %w[cool blah test]).inspect
#add comment
client.add_comment('I1MHJgBduvM', 'nice!')
#list comments
client.comments('I1MHJgBduvM')
#add favorite
client.add_favorite('I1MHJgBduvM')
#delete favorite
client.delete_favorite('H1TrfM3xbgc')
#add playlist
my_playlist = client.add_playlist(:title => "new playlist23", :description => "playlist description")
#add video to playlist
v = client.add_video_to_playlist("568FA69C0A7235D0", "I1MHJgBduvM")
#remove video from playlist
client.delete_video_from_playlist("568FA69C0A7235D0",v[:playlist_entry_id])
#update playlist
client.update_playlist("568FA69C0A7235D0", :title => "new playlist23", :description => "nice playlist")
#delete playlist
client.delete_playlist("568FA69C0A7235D0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment