ежедневная и крафты

This commit is contained in:
heyshawtyy committed 2026-11-19 13:46:05 +05:00
1 parent 828297cc6a
commit ce8184576e
31 files changed
+3371

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
# Uploads the craft .glb files as Model assets via Studio MCP open_cloud_invoke, polls the operations, writes asset_ids.json
import json, os, re, subprocess, sys, time
HERE = os.path.dirname(os.path.abspath(__file__))
GLB = r"C:\Users\писикакич\Desktop\ornaments\crafts\glb"
SID, UID = sys.argv[1], sys.argv[2]
def call(tool, args):
a = os.path.join(HERE, "args_up.json"); json.dump({**args, "studio_id": SID}, open(a, "w", encoding="utf-8"), ensure_ascii=False)
r = subprocess.run([sys.executable, os.path.join(HERE, "rbx.py"), tool, a], capture_output=True, text=True, encoding="utf-8")
return (r.stdout or "") + (r.stderr or "")
out = json.load(open(os.path.join(HERE, "asset_ids.json"))) if os.path.exists(os.path.join(HERE, "asset_ids.json")) else {}
names = sys.argv[3:] or [f[:-4] for f in sorted(os.listdir(GLB)) if f.endswith(".glb")]
for name in names:
if name in out: continue
body = {"request": {"assetType": "Model", "displayName": "Craft " + name, "description": "Christmas craft item",
"creationContext": {"creator": {"userId": UID}}}}
r = call("open_cloud_invoke", {"method": "POST", "endpoint": "/assets/v1/assets", "body": json.dumps(body),
"files": [{"name": "fileContent", "path": os.path.join(GLB, name + ".glb")}],
"scopes": ["asset:read", "asset:write"]})
m = re.search(r'operations/([0-9a-fA-F-]+)', r) or re.search(r'"operationId"\s*:\s*"([^"]+)"', r)
if not m: print(name, "UPLOAD FAILED:", r[:500]); continue
op = m.group(1)
for _ in range(30):
time.sleep(2)
s = call("open_cloud_invoke", {"method": "GET", "endpoint": "/assets/v1/operations/" + op, "scopes": ["asset:read"]})
a = re.search(r'"assetId"\s*:\s*"?(\d+)', s)
if a: out[name] = a.group(1); break
if '"done":true' in s.replace(" ", "") and not a: print(name, "OP DONE WITHOUT ID:", s[:400]); break
print(name, out.get(name, "TIMEOUT"))
json.dump(out, open(os.path.join(HERE, "asset_ids.json"), "w"), indent=1)