15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/yadisk/main.rb', line 15
def download(url, folder: ".#{File::SEPARATOR}", wget_options: nil)
enc_url = CGI::escape(url)
response = Net::HTTP.get(URI("#{BASE_URL}#{enc_url}"))
json_res = JSON.parse(response)
download_url = json_res['href']
filename = CGI::parse(URI(download_url).query)["filename"][0]
folder = folder + File::SEPARATOR if not folder.end_with?(File::SEPARATOR)
download_path = folder + filename
wget_options = (wget_options || "") + "--no-check-certificate" if Yadisk::OS.windows?
system("wget #{esc(download_url)} -O #{esc(download_path)} #{wget_options}")
end
|