aboutsummaryrefslogtreecommitdiff
path: root/lib/curl.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/curl.lua')
-rw-r--r--lib/curl.lua36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/curl.lua b/lib/curl.lua
index cfc1c11..4c56325 100644
--- a/lib/curl.lua
+++ b/lib/curl.lua
@@ -1,33 +1,33 @@
#!/usr/bin/env lua
-local util = require 'lib.util'
+local util = require("lib.util")
local def_headr = {
- ['User-Agent'] = 'cia',
- ['Accept-Encoding'] = 'gzip, deflate, br'
+ ["User-Agent"] = "cia",
+ ["Accept-Encoding"] = "gzip, deflate, br",
}
-local head_to_args = function (t)
+local head_to_args = function(t)
local args = {}
for k, v in pairs(t) do
- args[#args + 1] = '-H' .. k .. ": " .. v
+ args[#args + 1] = "-H" .. k .. ": " .. v
end
return args
end
-local get = function (url, headr, args)
+local get = function(url, headr, args)
local fetch, hcode, def_args
def_args = {
- 'curl',
- '--silent',
- '--compressed',
- '--write-out',
- '%{http_code}',
- '--globoff',
- '--location',
+ "curl",
+ "--silent",
+ "--compressed",
+ "--write-out",
+ "%{http_code}",
+ "--globoff",
+ "--location",
url,
}
@@ -36,17 +36,17 @@ local get = function (url, headr, args)
args = util.array_merge(args, head_to_args(headr))
fetch = util.run(args)
- hcode = fetch:match('%d*$')
- fetch = fetch:gsub('%s*%d*$', '')
+ hcode = fetch:match("%d*$")
+ fetch = fetch:gsub("%s*%d*$", "")
return fetch, tonumber(hcode)
end
-local zip_link_to_file = function (url, headr, out)
+local zip_link_to_file = function(url, headr, out)
local hcode, zip, rc, args
zip = os.tmpname()
- args = { '-o'.. zip }
+ args = { "-o" .. zip }
_, hcode = get(url, headr, args)
@@ -57,7 +57,7 @@ local zip_link_to_file = function (url, headr, out)
os.remove(zip)
if hcode and not rc then
- util.error('curl: zip_link_to_file')
+ util.error("curl: zip_link_to_file")
end
return rc