Skip to content

Instantly share code, notes, and snippets.

@natanael-araujo
Created May 21, 2012 07:08
Show Gist options
  • Save natanael-araujo/2760896 to your computer and use it in GitHub Desktop.
Save natanael-araujo/2760896 to your computer and use it in GitHub Desktop.
download all the screencasts from destroyallsoftware.com <3
# encoding: UTF-8
begin
require "mechanize"
rescue LoadError => e
p e; abort "please run \"gem install mechanize\""
end
download_path = File.expand_path(File.join(File.dirname(__FILE__), "destroy_all_software"))
Dir.mkdir download_path unless Dir.exists? download_path
agent = Mechanize.new
agent.pluggable_parser.default = Mechanize::Download
page = agent.get("https://www.destroyallsoftware.com/screencasts/users/sign_in")
page.form.tap do |form|
form.field_with("name" => "user[email]").value = "user@email.com"
form.field_with("name" => "user[password]").value = "password"
form.submit
end
# if you prefer iOS version use 'Download iOS' instead of only 'Download'
agent.page.links.find_all { |l| l.text == "Download" }.each do |link|
video_path = File.join(download_path, "#{link.uri.to_s.match(/catalog\/((\w*-*)*)/)[1]}.mov")
puts "Dowloading... #{video_path}"
link.click.save(video_path) unless File.exists? video_path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment