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

videos_by with racy: 'include' results in exception #57

Closed masterkain closed 12 years ago

masterkain commented 12 years ago

Hi, when doing a videos_by search if I specify a racy: 'include' as option I get an exception returning HTTP status 400.

chebyte commented 12 years ago

hi there can you show me a better example, what query did you make?

thanks

masterkain commented 12 years ago
@video = youtube_client.videos_by(categories: { either: [:music, :video] }, racy: true, only_embeddable: true, query: "immortal live", max_results: 1).videos.first

if you remove the racy param it works, otherwise it bombs:

OpenURI::HTTPError: 400
    from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:8:in `rescue in initialize'
    from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/youtube_it-2.0.1/lib/youtube_it/parser.rb:5:in `initialize'
    from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/youtube_it-2.0.1/lib/youtube_it/client.rb:74:in `new'
    from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/youtube_it-2.0.1/lib/youtube_it/client.rb:74:in `videos_by'
chebyte commented 12 years ago

thanks for this

you problem is that racy just allows the options include or exclude not TRUE

but we have another problem, racy was replaced by safeSearch param in the version 2 of api

I going to add this fix now cause we are using v2

thanks for this report!

chebyte commented 12 years ago

ok I added the new way now you can use safe_search with the follows options : none, strict, moderate

@video = youtube_client.videos_by(categories: { either: [:music, :video] }, safe_search: "none", only_embeddable: true, query: "immortal live", max_results: 1).videos.first

you can wait for the next release or use the code from github

cheers!

masterkain commented 12 years ago

awesome @chebyte , thanks!