# -*- 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 = [ (13203, 16916, "吕布PV_S3-2_关羽偃月刀"), (13204, 16917, "吕布PV_S3-3_张飞蛇矛"), (13205, 16915, "吕布PV_S3-4_刘备双剑"), (13206, 16918, "吕布PV_S3-5_吕布横扫三英"), (13207, 16919, "吕布PV_S3-6_三英震退"), ] 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 [] print(tid, name, "media_asset_id=", outs[0].get("media_asset_id") if outs else None) except urllib.error.HTTPError as e: print(tid, "HTTP", e.code, e.read().decode("utf-8")[:400])