-
-
Save jeremyjs/5d4cb855228ce24df9f5ac329539c4fc to your computer and use it in GitHub Desktop.
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 | |
# | |
# requirements: | |
# gem install mechanize | |
# | |
# usage: | |
# das_download.rb [download_directory] | |
require 'mechanize' | |
path = ARGV[0] || './' | |
download = lambda do |url, file| | |
agent = Mechanize.new | |
agent.pluggable_parser.default = Mechanize::Download | |
agent.get(url).save(file) | |
end | |
root = 'https://www.destroyallsoftware.com' | |
agent = Mechanize.new | |
agent.get("#{root}/screencasts/catalog") | |
screencasts = agent.page.search('div.episode').reverse | |
total = screencasts.size | |
resolution = '4k' | |
dwnld_slug = "download?resolution=#{resolution}" | |
index = 0 | |
while screencast = screencasts.pop | |
index += 1 | |
title = screencast.search('.title').first.text | |
url = "#{root}/#{screencast.search('a').first['href']}/#{dwnld_slug}" | |
file = "#{path}/#{'%03d' % index}_#{title.gsub(/\n\.|:|,/, '').gsub(/\/|\s+/, '-').downcase}.mp4" | |
puts "Downloading\t#{title.ljust(32)}\tas\t#{file.ljust(48)}\t| #{index}/#{total}" | |
next 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