-
-
Save jaredculp/f26f83d214cf926472dddd4269bd2538 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
@elochim-siemasz Does it still works for you?
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
Changed it a bit to work on Windows by replacing forbidden characters in filenames:
https://gist.github.com/elochim-siemasz/64edda44c2fcfc28d6b7eed9f78cd62c