Created
March 21, 2012 15:37
-
-
Save tallgreentree/2148611 to your computer and use it in GitHub Desktop.
Download all Destroy All Software Screencasts
This file contains 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
#! /usr/bin/env ruby | |
# usage: | |
# $ das_download.rb email password [download_directory] | |
require 'mechanize' | |
# gem 'mechanize-progressbar' | |
email = ARGV[0] or raise('Please provide the email address for your account') | |
password = ARGV[1] or raise('Please provide the password for your account') | |
path = ARGV[2] || './' | |
download = lambda do |url, file| | |
agent = Mechanize.new | |
agent.get 'https://www.destroyallsoftware.com/screencasts/users/sign_in' | |
form = agent.page.forms.first | |
form['user[email]'] = email | |
form['user[password]'] = password | |
form.submit | |
agent.pluggable_parser.default = Mechanize::Download | |
agent.get(url).save(file) | |
end | |
agent = Mechanize.new | |
agent.get 'https://www.destroyallsoftware.com/screencasts/catalog' | |
screencasts = agent.page.search('li.screencast').reverse | |
while screencast = screencasts.pop | |
title = screencast.search('a').first.text | |
url = screencast.search('.download_link > a:first-child').first['href'] | |
index = screencasts.size | |
file = "#{path}/#{"%03d" % (index + 1)}-#{title.gsub(/\.|:|,/, '').gsub(/\/|\s/, '-').downcase}.mov" | |
puts "Downloading #{title} - #{index} to go" | |
next puts 'Already Downloaded' if File.exist? file | |
download[url, file] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't think there is a download link anymore. This seems to work, although crude.
https://gist.github.com/ckahle33/b50d43f2d7c00c5e6082edb0b1c92cb1
run with
ruby ./das.rb