Il codice per scaricare e convertire:
#!/usr/bin/env ruby
require 'mechanize'
Mechanize.new.instance_eval do
get 'http://www.kinesioitalia.com/corsi_principale.php'
page.forms.first.tap do |f|
f['username'] = ""
f['password'] = ""
f.submit
end
get "http://www.kinesiotex.com/portal/systems/KinesioWebsite/jsp/screeningtests_enGB.kin"
links = page.search("#screeningtesttable").css("a")
links.each do |link|
get "http://www.kinesiotex.com/portal/systems/KinesioWebsite/jsp/#{ link["href"] }"
video_url = page.search(".maincontent").css("a.videolink").first["onclick"].scan(/'([^,]*)'/).flatten.first.scan(/applet_enGB_(.*)\.kin/).flatten.first.gsub(".avi", ".jar")
full_video_url = "http://www.kinesiotex.com/portal/systems/KinesioWebsite/jsp/jars/#{ video_url }"
get(full_video_url).save(video_url)
`jar xf #{ video_url }`
decoded = File.new("#{ video_url }.decoded.avi", "w")
File.open(video_url.gsub(".jar", ".avi"), 'r', binmode: true) do |file|
file.each_byte do |byte|
decoded.write((byte ^ 0b11100010).chr)
end
end
decoded.close
end
end
















