Skip to content

Instantly share code, notes, and snippets.

@rianrainey
Created April 3, 2018 19:37
Show Gist options
  • Save rianrainey/46c9f00f5504ee9c5c266818e32c2ebc to your computer and use it in GitHub Desktop.
Save rianrainey/46c9f00f5504ee9c5c266818e32c2ebc to your computer and use it in GitHub Desktop.
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