Created
June 2, 2013 16:15
-
-
Save alfredormz/5693990 to your computer and use it in GitHub Desktop.
Script to download my Destroy All Software screencast collection
This file contains hidden or 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 | |
require 'mechanize' | |
#usage das_dowloader.rb [destination_path] | |
URL = "https://www.dropbox.com/sh/cy20e9npok91qc4/FxNKaTDdqE/das?lst" | |
path = ARGV[0] || "." | |
agent = Mechanize.new | |
agent.pluggable_parser.default = Mechanize::Download | |
agent.get URL | |
links = agent.page.search("a.filename-link").map { |l| l['href'] } | |
links.each do |url| | |
agent.get(url) | |
download_button_link = agent.page.search("#download_button_link").first["href"] | |
screencast_filename = "#{url.split("/").last}" | |
target_filename = "#{path}/#{screencast_filename}" | |
unless File.exists? target_filename | |
puts "Downloading #{screencast_filename}" | |
agent.get(download_button_link).save target_filename | |
else | |
puts "#{screencast_filename} already downloaded" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment