Skip to content

Instantly share code, notes, and snippets.

@itsgoingd
Created August 5, 2018 15:11
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save itsgoingd/4e6f9b663a825143ebd6997806931e73 to your computer and use it in GitHub Desktop.
Save itsgoingd/4e6f9b663a825143ebd6997806931e73 to your computer and use it in GitHub Desktop.
Script to download all Destroy All Software screencasts w/ login (works as of Aug 2018)
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password
# based on various gists from this thread https://gist.github.com/maca/1798070
require "mechanize"
require "fileutils"
class DasDownloader
attr_reader :agent, :email, :password
def initialize(email, password)
@agent = Mechanize.new
@email, @password = email, password
end
def screencasts
screencasts = []
screencasts_metadata_html.each do |html|
next unless (meta = html.at("h1.season_title"))
season = meta.at("a").attr("name")
html.search(".episode").each do |episode|
title = episode.at(".title").text.gsub("/", "-")
url = episode.at("a").attr("href")
download_url = url + "/download"
description = episode.at(".subtitle").text
duration = episode.at(".duration").text
screencasts << Screencast.new(season, title, description, duration, download_url)
end
end
screencasts
end
def run
screencasts.each do |screencast|
if screencast.season != "Classic season 1" && screencast.season != "Classic season 2"
puts "#{screencast.season}"
download screencast
end
end
end
private
def replace(name)
name.gsub!(":", " ")
name.gsub!("/", " ")
name.gsub!("\\", " ")
name.gsub!("<", " ")
name.gsub!(">", " ")
name.gsub!("|", " ")
name.gsub!("?", " ")
name.gsub!("*", " ")
name.gsub!("\"", " ")
name
end
def login
agent.get "https://www.destroyallsoftware.com/screencasts/users/sign_in"
if (form = agent.page.forms.first)
form["user[email]"] = email
form["user[password]"] = password
form.submit
agent.pluggable_parser.default = Mechanize::Download
end
end
def download(screencast)
puts "Downloading #{screencast.season} - #{screencast.title}"
FileUtils::mkdir_p(replace screencast.season)
Dir.chdir(replace screencast.season) do
FileUtils::mkdir_p(replace screencast.title)
Dir.chdir(replace screencast.title) do
File.open("metadata.txt", "w") do |metadata|
metadata.puts "Title: #{screencast.title}"
metadata.puts "Description: #{screencast.description}"
metadata.puts "Duration: #{screencast.duration}"
end
agent.get("https://destroyallsoftware.com#{screencast.url}").save("screencast.mov")
end
end
end
def screencasts_metadata_html
login
agent.get "https://www.destroyallsoftware.com/screencasts/catalog"
agent.page.search(".season").reverse
end
Screencast = Struct.new(:season, :title, :description, :duration, :url)
end
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")
DasDownloader.new(email, password).run
@lukeholder
Copy link

Updated @itsgoingd's version to work better in Apr 2021 https://gist.github.com/lukeholder/64f6a3bbc97c050ddfa605fa4d5dff8c

  • Added the episode number to the filename and meta data
  • Cleaned up the title format (squish!)
  • Download as.mp4 extension
  • Removed tags ("Watched", "Free") from episode names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment