kylejginavan / youtube_it

An object-oriented Ruby wrapper for the YouTube GData API
http://groups.google.com/group/ruby-youtube-library
595 stars 223 forks source link

video_by(id) fails if video is private #120

Closed muffl0n closed 12 years ago

muffl0n commented 12 years ago

When trying to fetch a private video by id the request fails:

client = YouTubeIt::Client.new(:username => user, :password => password :dev_key => dev_key)

id = ARGV[0]
video = client.video_by(id)
/home/muffl0n/.gem/ruby/1.8/gems/youtube_it-2.1.7/lib/youtube_it/parser.rb:10:in `initialize': 403 (OpenURI::HTTPError)
        from /home/muffl0n/.gem/ruby/1.8/gems/youtube_it-2.1.7/lib/youtube_it/client.rb:97:in `new'
        from /home/muffl0n/.gem/ruby/1.8/gems/youtube_it-2.1.7/lib/youtube_it/client.rb:97:in `video_by'
        from youtube.rb:7

The URL youtube_it calls is

http://gdata.youtube.com/feeds/api/videos/<id>?v=2&key=<dev_key>

When I switch the video to public everything works fine.

The Youtube-API-Documentation (https://developers.google.com/youtube/2.0/reference#youtubeDataAPIFeedTypes) says:

Private, pending and rejected videos would not appear in a response to an unauthorized API request or a request for videos uploaded by someone other than the currently authenticated user.

So it seems that the API call doesn't know about the user I logged in with in the script.

muffl0n commented 12 years ago

It's not bug. The documentation for the methods to retrieve private videos was just missing. See #122 for pull request.