Youtube_It示例代码绘制参数错误

时间:2013-06-23 19:16:52

标签: ruby youtube youtube-api

我写了一些基本代码来尝试让图书馆工作。我在Windows 7上运行,我刚刚安装了youtube_it gem并试图从自述文件中运行一些示例代码,但是,我收到了一个令人费解的ArgumentError。这是我试图运行的代码:

#Test YouTube Ruby file. 
require 'youtube_it'
client = YouTubeIt::Client.new(:dev_key => "my developer key here)
client.videos_by(:query => "penguin", :max_results => 1)
client.videos.each do |video|
  video.title
  video.video_id
end

For reference, the error received was this: C:/RailsInstaller/Ruby1.9.3/lib/rubygems/1.9.1/gems/youtube_it-2.3.1/lib/youtube_it/request/video_upload.rb:265: in 'videos' wrong number of arguments (0 for 1) (ArgumentError).

关于如何对此进行故障排除的任何输入都会很棒。

1 个答案:

答案 0 :(得分:3)

首先,您需要关闭您的开发键引号

client = YouTubeIt::Client.new(:dev_key => "my developer key here")

这对我有用:

require 'youtube_it'
client = YouTubeIt::Client.new(:dev_key => "my developer key here")
response = client.videos_by(:query => "penguin")
response.videos.first.title

从那里尝试一下:

response.videos.each do |video|
  puts video.title
end

结果:

Pablo Penguin
Emperor penguins - The Greatest Wildlife Show on Earth - BBC
Penguin Fail - Best Bloopers from Penguins Spy in the Huddle
PoM - The Penguin Who Loved Me part 1
Scamper the Penguin (1988) - English Dubbed
Pet Penguin in Japan
Avicii - Penguin (Original mix)
CLUB PENGUIN....
penguin
Penguins very funny
Emperor Penguins in Antarctica
Christina Perri - Penguin (Official Lyric Video)
Club Penguin Unlock Item Codes (NEW) March 2013 Must Watch !!!! (HD)
Emperor Penguins Speed Launch Out of the Water
Avicii - 'Penguin' (Club Mix)
Cookie the Little Penguin at the Cincinnati Zoo
Penguin.avi
DONALD´S PENGUIN  1939
Penguins - BBC
Penguin Dilemma
Very happy Gentoo penguin
Zombie in a Penguin Suit
Penguin One
What should we expect in the next few months in terms of SEO for Google?
槇原敬之 - PENGUIN (2004年 日本武道館)