mirror of
https://github.com/Kiritow/OpenComputerScripts.git
synced 2024-03-22 13:10:46 +08:00
Update Grab
This commit is contained in:
parent
badbb77f40
commit
2b6f456c8c
34
grab.lua
34
grab.lua
|
@ -9,10 +9,17 @@ if( (#args<1 and (not options["setup"])) or options["help"]) then
|
||||||
print("Options:"
|
print("Options:"
|
||||||
.. "\n\t--cn Use mirror site in China. By default grab will download from Github."
|
.. "\n\t--cn Use mirror site in China. By default grab will download from Github."
|
||||||
.. "\n\t--help Display this help page."
|
.. "\n\t--help Display this help page."
|
||||||
.. "\n\t--setup Download some basic files for development"
|
.. "\n\t--setup Download some basic files for development."
|
||||||
|
.. "\n\t--version Display version and exit."
|
||||||
|
.. "\n\t--proxy=<Proxy File> Given a proxy file which will be loaded and returns a proxy function like: "
|
||||||
|
.. "function(RepoName: string, Branch: string ,FileAddress: string): string"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if(options["version"]) then
|
||||||
|
print("Grab v1.1")
|
||||||
|
return
|
||||||
|
end
|
||||||
local function download(url)
|
local function download(url)
|
||||||
if(component.internet==nil) then
|
if(component.internet==nil) then
|
||||||
error("This program requires an Internet card.")
|
error("This program requires an Internet card.")
|
||||||
|
@ -37,13 +44,28 @@ local function download(url)
|
||||||
return true,result,code
|
return true,result,code
|
||||||
end
|
end
|
||||||
local UrlGenerator
|
local UrlGenerator
|
||||||
if(not options["cn"]) then
|
if(not options["proxy"]) then
|
||||||
UrlGenerator=function(RepoName,Branch,FileAddress)
|
if(not options["cn"]) then
|
||||||
return "https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
|
UrlGenerator=function(RepoName,Branch,FileAddress)
|
||||||
|
return "https://raw.githubusercontent.com/" .. RepoName .. "/" .. Branch .. "/" .. FileAddress
|
||||||
|
end
|
||||||
|
else
|
||||||
|
UrlGenerator=function(RepoName,Branch,FileAddress)
|
||||||
|
return "http://kiritow.com:3000/" .. RepoName .. "/raw/" .. Branch .. "/" .. FileAddress
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
UrlGenerator=function(RepoName,Branch,FileAddress)
|
local ok,err=pcall(function()
|
||||||
return "http://kiritow.com:3000/" .. RepoName .. "/raw/" .. Branch .. "/" .. FileAddress
|
local f=io.open(options["proxy"],"r")
|
||||||
|
if(f==nil) then error("Proxy file not found") end
|
||||||
|
local src=f:read("a")
|
||||||
|
f:close()
|
||||||
|
local fn=load(src)
|
||||||
|
UrlGenerator=fn()
|
||||||
|
end)
|
||||||
|
if(not ok) then
|
||||||
|
print("Proxy file error: " .. err)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local files
|
local files
|
||||||
|
|
Loading…
Reference in New Issue
Block a user