This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
fs.makeDir("GuiH") | ||
local github_api = http.get( | ||
"https://api.github.com/repos/9551-Dev/GuiH/git/trees/main?recursive=1", | ||
_G._GIT_API_KEY and {Authorization = 'token ' .. _G._GIT_API_KEY} | ||
) | ||
|
||
local list = textutils.unserialiseJSON(github_api.readAll()) | ||
local ls = {} | ||
local len = 0 | ||
github_api.close() | ||
for k,v in pairs(list.tree) do | ||
if v.type == "blob" and v.path:lower():match(".+%.lua") then | ||
ls["https://raw.githubusercontent.com/9551-Dev/GuiH/main/"..v.path] = v.path | ||
len = len + 1 | ||
end | ||
end | ||
local percent = 100/len | ||
local finished = 0 | ||
local size_gained = 0 | ||
local downloads = {} | ||
for k,v in pairs(ls) do | ||
table.insert(downloads,function() | ||
local web = http.get(k) | ||
local file = fs.open("/tmp/GuiH/"..v,"w") | ||
file.write(web.readAll()) | ||
file.close() | ||
web.close() | ||
finished = finished + 1 | ||
local file_size = fs.getSize("/tmp/GuiH/"..v) | ||
size_gained = size_gained + file_size | ||
print("downloading "..v.." "..tostring(math.ceil(finished*percent)).."% "..tostring(math.ceil(file_size/1024*10)/10).."kB total: "..math.ceil(size_gained/1024).."kB") | ||
end) | ||
end | ||
parallel.waitForAll(table.unpack(downloads)) | ||
print("Finished downloading GuiH") |