如何使用 Ruby 获取 youtube 视频的数据?例如,我有这样一个视频的 api url:(例如 https://gdata.youtube.com/feeds/api/videos/6Dakd7EIgBE?v=2
)。如何使用 Ruby 将 View 、投票、缩略图等元素提取到我的 Rails 应用程序中?
最佳答案
Ruby gem 从视频中获取信息。查看此链接。 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>'"
关于ruby-on-rails - 如何通过 API 将 YouTube 视频详细信息导入 Rails 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22278937/