Skip to content

Instantly share code, notes, and snippets.

@jaredculp
Forked from jasondew/das_download.rb
Last active July 3, 2018 04:19
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save jaredculp/f26f83d214cf926472dddd4269bd2538 to your computer and use it in GitHub Desktop.
Save jaredculp/f26f83d214cf926472dddd4269bd2538 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
# usage:
# $ das_download.rb
require "mechanize"
require "fileutils"
class DasDownloader
attr_reader :agent, :email, :password
def initialize
@agent = Mechanize.new
end
def screencasts
screencasts = []
screencasts_metadata_html.each do |html|
next unless (meta = html.at("h1.season_title"))
season = meta.at("img").attr("alt")
html.search(".episode").each do |episode|
number = "%02d" % episode.at(".number").text.to_i
title = episode.at(".title").text.gsub("/", "-")
.gsub(" ", "_")
.downcase
url = episode.at("a").attr("href")
download_url = url + "/download"
screencasts << Screencast.new(season, number, title, download_url)
end
end
screencasts
end
def run
screencasts.each do |screencast|
download screencast
end
end
private
def download(screencast)
puts "Downloading #{screencast.season} - #{screencast.title}"
FileUtils::mkdir_p(screencast.season)
Dir.chdir(screencast.season) do
agent.get("https://destroyallsoftware.com#{screencast.url}")
.save("#{screencast.number}-#{screencast.title}.mov")
end
end
def screencasts_metadata_html
agent.get "https://www.destroyallsoftware.com/screencasts/catalog"
agent.page.search(".season").reverse
end
Screencast = Struct.new(:season, :number, :title, :url)
end
DasDownloader.new.run
@elo-siema
Copy link

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

@vinitkumar
Copy link

@elochim-siemasz Does it still works for you?

@Omar-Elrefaei
Copy link

O $h*t this worked perfectly !!!
Thanks so much ❤️

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