wayback-machine-downloader/bin/wayback_machine_downloader
tedder 1eaa8098c0
add --exclude filter
- add exclude filter. Has precedence over the --only filter.
- bumped the version.
- tests: I modified the tests, but.. the whole suite is hopelessly broken. And when I say hopeless, I'm talking about myself; my Ruby is so rudimentary I was looking up how to create a variable. It really needs a static list of the website 'contents' mocked into it. I have a branch in my repo showing my hopeless work.
2016-06-28 23:27:36 -07:00

43 lines
1.5 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 any website from the Wayback Machine."
opts.separator ""
opts.separator "Optional options:"
opts.on("-t", "--timestamp TIMESTAMP", Integer, "Only files on or before timestamp supplied (ie. 20150806225358)") do |t|
options[:timestamp] = t
end
opts.on("-o", "--only ONLY_FILTER", String, "Restrict downloading to file urls matching the only filter supplied (use // notation for the only filter to be treated as a regex)") do |t|
options[:only_filter] = t
end
opts.on("-x", "--exclude EXCLUDE_FILTER", String, "Skip 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("-v", "--version", "Display version") do |t|
options[:version] = t
end
end.parse!
if (base_url = ARGV[-1])
wayback_machine_downloader = WaybackMachineDownloader.new base_url: base_url, timestamp: options[:timestamp], only_filter: options[:only_filter], exclude_filter: options[:exclude_filter]
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