Skip to content

Instantly share code, notes, and snippets.

@milk1000cc
Created January 24, 2009 10:00
Show Gist options
  • Save milk1000cc/51392 to your computer and use it in GitHub Desktop.
Save milk1000cc/51392 to your computer and use it in GitHub Desktop.
require 'open-uri'
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::HTML(URI(ARGV[0]).read)
id = doc.at('//embed[starts-with(@src, "http://www.dailymotion.com/swf/")]')['src'].sub(%r!^http://www.dailymotion.com/swf/!, '')
html = URI("http://www.dailymotion.com/video/#{ id }").read
if html =~ /\.addVariable\("video", "(.+?)"/
if URI.decode($1) =~ %r!(/get/\d+?/\d+?x\d+?/h264/.+?\.h264\?key=.+?)@!
puts URI.encode(%(javascript:document.write('<a href="http://www.dailymotion.com#{ $1 }">download</a>')))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment