wayback-machine-downloader/bin/wayback_machine_downloader
2015-11-19 15:26:20 -06:00

39 lines
1.3 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("-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]
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