Add all file types download option

This commit is contained in:
hartator 2016-07-31 09:51:27 -05:00
parent b8f0bc46f3
commit 7ca5f579d5
3 changed files with 15 additions and 2 deletions

View File

@ -30,6 +30,10 @@ option_parser = OptionParser.new do |opts|
options[:exclude_filter] = t options[:exclude_filter] = t
end 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| opts.on("-v", "--version", "Display version") do |t|
options[:version] = t options[:version] = t
end end

View File

@ -10,7 +10,7 @@ class WaybackMachineDownloader
VERSION = "0.4.1" VERSION = "0.4.1"
attr_accessor :base_url, :from_timestamp, :to_timestamp, :only_filter, :exclude_filter attr_accessor :base_url, :from_timestamp, :to_timestamp, :only_filter, :exclude_filter, :all
def initialize params def initialize params
@base_url = params[:base_url] @base_url = params[:base_url]
@ -18,6 +18,7 @@ class WaybackMachineDownloader
@to_timestamp = params[:to_timestamp].to_i @to_timestamp = params[:to_timestamp].to_i
@only_filter = params[:only_filter] @only_filter = params[:only_filter]
@exclude_filter = params[:exclude_filter] @exclude_filter = params[:exclude_filter]
@all = params[:all]
end end
def backup_name def backup_name
@ -55,7 +56,10 @@ class WaybackMachineDownloader
end end
def get_file_list_curated def get_file_list_curated
parameters_for_wayback_machine_api = "&fl=timestamp,original&fastLatest=true&filter=statuscode:200&collapse=original" parameters_for_wayback_machine_api = "&fl=timestamp,original&collapse=original"
unless @all
parameters_for_wayback_machine_api += "&filter=statuscode:200"
end
if @from_timestamp and @from_timestamp != 0 if @from_timestamp and @from_timestamp != 0
parameters_for_wayback_machine_api += "&from=" + @from_timestamp.to_s parameters_for_wayback_machine_api += "&from=" + @from_timestamp.to_s
end end

View File

@ -76,4 +76,9 @@ class WaybackMachineDownloaderTest < Minitest::Test
assert_nil @wayback_machine_downloader.get_file_list_curated["linux.htm"] assert_nil @wayback_machine_downloader.get_file_list_curated["linux.htm"]
end end
def test_file_list_exclude_filter_with_a_regex
@wayback_machine_downloader.all = true
assert_equal 69, @wayback_machine_downloader.get_file_list_curated.size
end
end end