# -*- 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 = [ (13249, 16965, "吕布PV场景板v3_S03_虎牢关下战场_Seedream"), (13250, 16966, "吕布PV场景板v3_S08_下邳雨夜_Seedream"), ] 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")[:500])