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

REXML::ParseException: #<RuntimeError: Illegal character '&' in raw string " #30

Closed bogn closed 12 years ago

bogn commented 13 years ago

Using ruby-1.9.2-p180 or ruby-1.9.3-rc1 the exception can be reproduced as follows: client = YouTubeIt::Client.new client.video_by("http://www.youtube.com/watch?v=ll68RgUIbks") or client.video_by("http://www.youtube.com/watch?v=wKjmbt_eTMs")

I'm aware that it works when you parse the unique_id yourself, but I'm quite sure most people expect this to be the responsiblity of the gem. And if a plain call to video_by can't be bothered to handle this, there should at least be a possibility to do this for example like so: client.video_by(:url => "http://www.youtube.com/watch?v=wKjmbt_eTMs")

I think a lot of the users of this gem have their visitors pasting some YouTube-URL into an input field, so this would save them from parsing stuff on their own (which isn't likely to be future proof) e.g. like:

def get_unique_id
  uri = Addressable::URI.parse(youtube_url)
  if uri.path == "/watch"
    uri.query_values["v"] if uri.query_values
  else
    uri.path
  end
end

If the gem would do it, the devs could rely on it to handle future changes to the URL schema and could ideally just update it, and everyting works again.

sairam commented 12 years ago

+1

sairam commented 12 years ago

My issue got fixed by unsetting the http_proxy variable. http_proxy was set to '' (empty string)

In line 75 of client.rb (parser.parse) was trying to parse the url itself. If it was unable to download the content, the url itself is being returned and being tried to be parsed

      parser = YouTubeIt::Parser::VideosFeedParser.new(request.url)
      parser.parse
chebyte commented 12 years ago

@bogn thanks for this advise we are working on that right now, tomorrow we going to push this fix

cheers!

chebyte commented 12 years ago

@bogn now you can find a video like this

client.video_by("http://gdata.youtube.com/feeds/videos/EkF4JD2rO3QE")
client.video_by("http://www.youtube.com/watch?v=8WVTOUh53QY&feature=feedf")
client.video_by("8WVTOUh53QY")
client.video_by("http://youtu.be/6vW0cg3ranw")

Best, Mauro