THpubs
THpubs

Reputation: 8172

How to get YouTube video details through the API into a Rails app?

Using Ruby, how can I get the data of a youtube video? For example, I have the api url of a video like this : (for example https://gdata.youtube.com/feeds/api/videos/6Dakd7EIgBE?v=2). How can I extract the elements like Views, Votes, Thumbnail into my rails app using Ruby?

Upvotes: 3

Views: 3552

Answers (1)

Kyaw Myint Thein
Kyaw Myint Thein

Reputation: 540

Ruby gem to get information from vedio. Check out this link. https://github.com/thibaudgg/video_info

gem install video_info

video = VideoInfo.new("http://www.youtube.com/watch?v=mZqGqE0D0n4")
# video.available?       => true
# video.video_id         => "mZqGqE0D0n4"
# video.provider         => "YouTube"
# video.title            => "Cherry Bloom - King Of The Knife"
# video.description      => "The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net"
# video.duration         => 175 (in seconds)
# video.date             => Sat Apr 12 22:25:35 UTC 2008
# video.thumbnail_small  => "http://i.ytimg.com/vi/mZqGqE0D0n4/default.jpg"
# video.thumbnail_medium => "http://i.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg"
# video.thumbnail_large  => "http://i.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg"
# video.embed_url        => "http://www.youtube.com/embed/mZqGqE0D0n4"
# video.embed_code       => "'<iframe src="//www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen"></iframe>'"

Upvotes: 5

Related Questions