On Tue, Apr 08, 2008 at 05:18:15AM +0900, comopasta Gr wrote:
> I'm just doing the research but maybe someone already knows...
> 
> I have a youtube video url:
> http://www.youtube.com/watch?v=n1NVfDlU6yQ&feature=related
> (&feature might or might not be present)
> 
> I can get the thum of the video using:
> http://img.youtube.com/vi/n1NVfDlU6yQ/default.jpg
> 
> So, I just need to use the video id.
> 
> Now, how to extract the video id easily? Eval?
> Yeah simple I know...I'm working on it in the meanwhile.

irb(main):001:0> require 'uri'
=> true
irb(main):002:0> uri = URI.parse('http://www.youtube.com/watch?v=n1NVfDlU6yQ&feature=related')
=> #<URI::HTTP:0x1b1066 URL:http://www.youtube.com/watch?v=n1NVfDlU6yQ&feature=related>
irb(main):003:0> require 'cgi'
=> true
irb(main):004:0> query_string = CGI.parse(uri.query)
=> {"feature"=>["related"], "v"=>["n1NVfDlU6yQ"]}

marcel
-- 
Marcel Molina Jr. <marcel / vernix.org>