mirror of
https://github.com/StrawberryMaster/wayback-machine-downloader.git
synced 2025-12-19 02:36:38 +00:00
Setting file modified time to value reported by Wayback Machine
Implements 937306712c564e5757d898feacc14fbabd10722d, fixes Maintain original creation/modified dates of files while downloading #174
This commit is contained in:
parent
0a7752eb41
commit
509d7034a1
@ -6,6 +6,7 @@ require 'open-uri'
|
|||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
requite 'time'
|
||||||
require_relative 'wayback_machine_downloader/tidy_bytes'
|
require_relative 'wayback_machine_downloader/tidy_bytes'
|
||||||
require_relative 'wayback_machine_downloader/to_regex'
|
require_relative 'wayback_machine_downloader/to_regex'
|
||||||
require_relative 'wayback_machine_downloader/archive_api'
|
require_relative 'wayback_machine_downloader/archive_api'
|
||||||
@ -264,6 +265,7 @@ class WaybackMachineDownloader
|
|||||||
file_id = file_remote_info[:file_id]
|
file_id = file_remote_info[:file_id]
|
||||||
file_timestamp = file_remote_info[:timestamp]
|
file_timestamp = file_remote_info[:timestamp]
|
||||||
file_path_elements = file_id.split('/')
|
file_path_elements = file_id.split('/')
|
||||||
|
original_file_mtime = nil
|
||||||
if file_id == ""
|
if file_id == ""
|
||||||
dir_path = backup_path
|
dir_path = backup_path
|
||||||
file_path = backup_path + 'index.html'
|
file_path = backup_path + 'index.html'
|
||||||
@ -285,6 +287,11 @@ class WaybackMachineDownloader
|
|||||||
begin
|
begin
|
||||||
http.get(URI("https://web.archive.org/web/#{file_timestamp}id_/#{file_url}")) do |body|
|
http.get(URI("https://web.archive.org/web/#{file_timestamp}id_/#{file_url}")) do |body|
|
||||||
file.write(body)
|
file.write(body)
|
||||||
|
|
||||||
|
if uri.meta.has_key?("x-archive-orig-last-modified")
|
||||||
|
original_file_mtime = Time.parse(uri.meta["x-archive-orig-last-modified"])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
rescue OpenURI::HTTPError => e
|
rescue OpenURI::HTTPError => e
|
||||||
puts "#{file_url} # #{e}"
|
puts "#{file_url} # #{e}"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user