wayback-machine-downloader/bin/wayback_machine_downloader
2016-07-31 09:51:38 -05:00

52 lines
1.7 KiB
Ruby
Executable File

#!/usr/bin/env ruby
require_relative '../lib/wayback_machine_downloader'
require 'optparse'
require 'pp'
options = {}
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: wayback_machine_downloader http://example.com"
opts.separator ""
opts.separator "Download an entire website from the Wayback Machine."
opts.separator ""
opts.separator "Optional options:"
opts.on("-f", "--from TIMESTAMP", Integer, "Only files on or after timestamp supplied (ie. 20060716231334)") do |t|
options[:from_timestamp] = t
end
opts.on("-t", "--to TIMESTAMP", Integer, "Only files on or before timestamp supplied (ie. 20100916231334)") do |t|
options[:to_timestamp] = t
end
opts.on("-o", "--only ONLY_FILTER", String, "Restrict downloading to urls that match this filter (use // notation for the filter to be treated as a regex)") do |t|
options[:only_filter] = t
end
opts.on("-x", "--exclude EXCLUDE_FILTER", String, "Skip downloading of urls that match this filter (use // notation for the filter to be treated as a regex)") do |t|
options[:exclude_filter] = t
end
opts.on("-a", "--all", "Expand downloading to error files (40x and 50x) and redirections (30x)") do |t|
options[:all] = true
end
opts.on("-v", "--version", "Display version") do |t|
options[:version] = t
end
end.parse!
if (base_url = ARGV[-1])
options[:base_url] = base_url
wayback_machine_downloader = WaybackMachineDownloader.new options
wayback_machine_downloader.download_files
elsif options[:version]
puts WaybackMachineDownloader::VERSION
else
puts "You need to specify a website to backup. (e.g., http://example.com)"
puts "Run `wayback_machine_downloader --help` for more help."
end