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

properly encode ampersand in video search #62

Closed kylefleming closed 12 years ago

kylefleming commented 12 years ago

if you search for something with an ampersand it won't encode the character properly. This is because it's using URI.encode not CGI.escape. See http://bugs.ruby-lang.org/issues/1680

URI.encode :

001:0> YouTubeIt::Client.new(:debug => true).videos_by(:query => "Stephen Malkmus & The Jicks Fall Away").videos[0].title
Submitting request [url=http://gdata.youtube.com/feeds/api/videos?max-results=25&q=Stephen+Malkmus+&+The+Jicks+Fall+Away&start-index=1&v=2].
=> "Stephen Malkmus and The Jicks - \"Senator\""

CGI.escape :

007:0> YouTubeIt::Client.new(:debug => true).videos_by(:query => "Stephen Malkmus & The Jicks Fall Away").videos[0].title
Submitting request [url=http://gdata.youtube.com/feeds/api/videos?max-results=25&q=Stephen+Malkmus+%26+The+Jicks+Fall+Away&start-index=1&v=2].
=> "Stephen Malkmus & the Jicks - Fall Away"

(I also fixed some of the other tests)