Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password [download_directory]
require "mechanize"
class DasDownloader
attr_reader :agent, :email, :password
def initialize(email, password)
@agent = Mechanize.new
@email, @password = email, password
end
def screencasts
screencasts_metadata_html.map do |html|
next unless (meta = html.at(".title a"))
title = meta.text
url = meta.attr("href")
download_url = url + "/download"
description = agent.get(url).at(".details p").text.strip
category = html.at(".category").text
duration = html.at(".duration").text
Screencast.new title, category, duration, description, download_url
end
end
def run
screencasts.each do |screencast|
download screencast
end
end
private
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.title}"
login
Dir.mkdir(screencast.title)
Dir.chdir(screencast.title) do
File.open("metadata.txt", "w") do |metadata|
metadata.puts "Title: #{screencast.title}"
metadata.puts "Category: #{screencast.category}"
metadata.puts "Duration: #{screencast.duration}"
metadata.puts "Description: #{screencast.description}"
end
agent.get(screencast.url).save("screencast.mov")
end
end
def screencasts_metadata_html
login
agent.get "https://www.destroyallsoftware.com/screencasts/catalog"
agent.page.search(".screencast").reverse
end
Screencast = Struct.new(:title, :category, :duration, :description, :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
@gudnm

This comment has been minimized.

Copy link

gudnm commented Sep 17, 2016

Does this still work?

@dprandzioch

This comment has been minimized.

Copy link

dprandzioch commented Nov 3, 2016

Nope :-(

@jaredculp

This comment has been minimized.

Copy link

jaredculp commented Apr 5, 2018

@gudnm @dprandzioch I've forked this and updated it to work with the latest since DAS is free this week: https://gist.github.com/jaredculp/f26f83d214cf926472dddd4269bd2538

@elo-siema

This comment has been minimized.

Copy link

elo-siema commented Apr 6, 2018

@jaredculp
Changed it a bit to work on Windows by replacing forbidden characters in filenames:
https://gist.github.com/elochim-siemasz/64edda44c2fcfc28d6b7eed9f78cd62c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.