Created
May 21, 2012 07:08
-
-
Save natanael-araujo/2760896 to your computer and use it in GitHub Desktop.
download all the screencasts from destroyallsoftware.com <3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "[email protected]" | |
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