This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
113 lines (92 loc) · 2.35 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
local fs = require("@lune/fs")
local net = require("@lune/net")
local process = require("@lune/process")
local roblox = require("@lune/roblox")
local GROUP_ID
local INPUT_NAME
local CONTENT_URI_PREFIX = "rbxassetid://"
local CONTENT_URI_PREFIX_ENABLED = false
local VERBOSE = false
function log(...)
if VERBOSE then
print(...)
end
end
if process.args[1] then
INPUT_NAME = process.args[1]
else
error("No input file specified.")
end
for index, arg in process.args do
if arg == "-g" or arg == "--group" then
GROUP_ID = process.args[index + 1]
elseif arg == "-v" or arg == "--verbose" then
VERBOSE = true
elseif arg == "-u" or arg == "--uri" then
CONTENT_URI_PREFIX_ENABLED = true
end
end
if not INPUT_NAME then
error("No input file specified.")
end
if GROUP_ID and not tonumber(GROUP_ID) then
error("Group ID specified, but it's not a number.")
end
local input = fs.readFile(INPUT_NAME)
local deser = roblox.deserializeModel(input)[1]
local URL = "https://www.roblox.com/ide/publish/uploadnewanimation"
local COOKIE = roblox.getAuthCookie()
log("Getting CSRF token")
local getCSRF = net.request({
url = URL,
method = "POST",
headers = {
["Cookie"] = COOKIE,
["Content-Type"] = "application/xml",
},
})
local csrf = getCSRF.headers["x-csrf-token"]
if not csrf then
error("Wasn't able to get CSRF token")
end
log(`CSRF token: {csrf}`)
local output = ""
for _, anim in deser:GetChildren() do
if anim.ClassName ~= "KeyframeSequence" then
continue
end
log(`Uploading {anim.Name}`)
local res = net.request({
url = URL,
method = "POST",
headers = {
["Cookie"] = COOKIE,
["Content-Type"] = "application/xml",
["User-Agent"] = "RobloxStudio/WinInet",
["Requester"] = "Client",
["X-CSRF-TOKEN"] = csrf,
},
query = {
["assetTypeName"] = "animation",
["name"] = anim.Name,
["description"] = "Uploaded with bulk-animation-upload",
["AllID"] = "1",
["ispublic"] = "false",
["allowComments"] = "false",
["isGamesAsset"] = "false",
["groupId"] = GROUP_ID,
},
body = input,
})
if not res.ok then
error(`Failed to upload {anim.Name}: {res.statusCode} {res.statusMessage}`)
end
log(`Uploaded {anim.Name}`)
local id = res.body
if CONTENT_URI_PREFIX_ENABLED then
id = CONTENT_URI_PREFIX .. id
end
output = `{output}{anim.Name}: {id}\n`
end
fs.writeFile("output.txt", output)
log("Results written to output.txt")