Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Download DAS
#! /usr/bin/env ruby
require 'mechanize'
agent = Mechanize.new
agent.pluggable_parser.default = Mechanize::Download
agent.get 'https://www.destroyallsoftware.com/screencasts/catalog'
episodes = agent.page.search('.episode > a').map { |a| a['href'] }
puts episodes
episodes_meta = episodes.map do |screencast, index|
page = agent.get 'https://www.destroyallsoftware.com' + screencast
puts page.title
url = page.search('video + script').first.children.first.to_s.match(/\s+source\.src\s=\s"(.+?)"/)[1]
puts url
title = URI(url).path[1..-1]
{ url: url, title: title }
end
puts "About to download #{episodes_meta.length} episodes... hold tight."
episodes_meta.each_slice(14) do |slice|
fork do
slice.each do |meta|
system('wget', '--quiet', '-O', meta[:title], meta[:url])
puts "Finished #{meta[:title]}"
end
end
end
Process.waitall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment