# -*- coding: utf-8 -*- import json, ssl, pathlib, urllib.request, urllib.error BASE = "https://192.168.31.88:8042" CFG = pathlib.Path(r"C:\Users\admin\.zcode\cli\config.json") pat = json.loads(CFG.read_text(encoding="utf-8-sig"))["mcp"]["servers"]["sorb"]["env"]["SORB_PAT"] ctx = ssl._create_unverified_context() items = [ (13086, 16800, "吕布PV_S1-1_锁人物锁马_古道冲关"), (13087, 16799, "吕布PV_S1-2_锁赤兔_踏雪特写"), (13088, 16801, "吕布PV_S1-3_锁吕布_英雄镜头"), ] for tid, oid, name in items: payload = json.dumps({"resource_name": name}, ensure_ascii=False).encode("utf-8") req = urllib.request.Request( BASE + "/api/external/v1/tasks/%d/outputs/%d/save" % (tid, oid), data=payload, method="POST", headers={"Authorization": "Bearer " + pat, "Content-Type": "application/json"}, ) try: with urllib.request.urlopen(req, context=ctx, timeout=60) as r: o = json.loads(r.read().decode("utf-8")) outs = o.get("outputs") or [] mid = outs[0].get("media_asset_id") if outs else None print(tid, "saved", name, "media_asset_id=", mid) except urllib.error.HTTPError as e: print(tid, "HTTP", e.code, e.read().decode("utf-8")[:500])