X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwget_downloader.rb;h=82235d594bd34408d5cb464dcb88eefd6e0618a4;hb=e72d484c8bf3e719f3f65ada1398772853836a56;hp=825ee12b9865f556733e4d05078036990d068fff;hpb=9a5310260a276a57c084d07de2bb97d78ce2a8ff;p=dead%2Fwhatever-dl.git diff --git a/src/wget_downloader.rb b/src/wget_downloader.rb index 825ee12..82235d5 100644 --- a/src/wget_downloader.rb +++ b/src/wget_downloader.rb @@ -18,7 +18,7 @@ class WgetDownloader < Downloader - def download(url, outfile, continue=false) + def download(url, outfile, headers = {}, continue = false) if (continue == false and File.exists?(outfile)) raise IOError.new("Output file already exists. Please remove #{outfile}, and try again. If this is a partially-downloaded file, you can use the --continue flag to pick up where it left off.") end @@ -26,11 +26,15 @@ class WgetDownloader < Downloader options = '' if continue == true - options += '--continue' + options += '--continue ' + end + + headers.each_key do |key| + options += "--header '#{key}: #{headers[key]}' " end # This one's easy. - cmd = "wget #{options} -O \"#{outfile}\" \"#{url}\"" + cmd = "wget #{options} -O '#{outfile}' '#{url}'" puts "\nExecuting external command: #{cmd}\n\n" Kernel.exec(cmd) end