import hashlib
import json
import os
import requests
APP_KEY = os.environ["GHOSTCUT_APP_KEY"]
APP_SECRET = os.environ["GHOSTCUT_APP_SECRET"]
BASE_URL = "https://api.zhaoli.com"
VIDEO_URL = "https://example.com/input.mp4"
def post(path, payload):
body = json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
body_md5 = hashlib.md5(body.encode("utf-8")).hexdigest()
app_sign = hashlib.md5((body_md5 + APP_SECRET).encode("utf-8")).hexdigest()
response = requests.post(
BASE_URL + path,
headers={
"Content-Type": "application/json",
"AppKey": APP_KEY,
"AppSign": app_sign,
},
data=body.encode("utf-8"),
timeout=30,
)
response.raise_for_status()
return response.json()
payload = {
"urls": [VIDEO_URL],
"needChineseOcclude": 2,
"videoInpaintLang": "all",
"extraOptions": json.dumps(
{"extra_inpaint_config": {"model": "advanced_lite"}},
separators=(",", ":"),
),
"videoInpaintMasks": json.dumps(
[{
"type": "remove_only_ocr",
"start": 0,
"end": 99999,
"region": [[0, 0], [1, 0], [1, 1], [0, 1]],
}],
separators=(",", ":"),
),
}
result = post("/v-w-c/gateway/ve/work/free", payload)
work_id = result["body"]["dataList"][0]["id"]
print("work_id:", work_id)
status = post("/v-w-c/gateway/ve/work/status", {"idWorks": [work_id]})
print(json.dumps(status, ensure_ascii=False, indent=2))
Replace VIDEO_URL with your own public video URL. Local videos must be uploaded first to obtain an accessible URL. Set AppKey and AppSecret through environment variables before running.
01
The signature and request body must match
The example serializes payload into compact JSON, generates the request header with AppSign = md5(md5(body_str) + AppSecret), and sends the exact same body_str.
02
Task creation only means it entered the queue
After /work/free succeeds, save body.dataList[0].id. Query normal video results with /work/status; processStatus == 1 means processing succeeded.
03
Upload local media first
For local media, request upload credentials first, upload the file to OSS, and use the returned URL in later API calls.