feat: full format compatibility adaptation for model downloads
- Add get_model_urls() and download_model() to api.py and api_complete.py supporting all 14 discovered urlResult format keys (glb, obj, pbr maps, etc.) - Update generator.py to extract full urlResult dict instead of just modelUrl - Add CLI subcommands: formats (list available formats) and download (fetch by key) - Update reverse engineering docs with complete format key table and CLI examples
This commit is contained in:
@@ -68,7 +68,7 @@ def generate_3d(image_path, wait_for_complete=False, timeout=300):
|
||||
page = context.new_page()
|
||||
|
||||
# 用于存储结果
|
||||
result = {"creationsId": None, "status": None, "modelUrl": None}
|
||||
result = {"creationsId": None, "status": None, "urlResult": {}}
|
||||
|
||||
# 监听响应
|
||||
def handle_response(response):
|
||||
@@ -79,7 +79,7 @@ def generate_3d(image_path, wait_for_complete=False, timeout=300):
|
||||
if "creationsId" in body:
|
||||
result["creationsId"] = body["creationsId"]
|
||||
print(f"✅ 生成已触发,creationsId: {body['creationsId']}")
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
elif "creations/detail" in url and response.status == 200:
|
||||
try:
|
||||
@@ -87,9 +87,13 @@ def generate_3d(image_path, wait_for_complete=False, timeout=300):
|
||||
result["status"] = body.get("status")
|
||||
if "result" in body and isinstance(body["result"], list) and len(body["result"]) > 0:
|
||||
model_data = body["result"][0]
|
||||
if "modelUrl" in model_data:
|
||||
result["modelUrl"] = model_data["modelUrl"]
|
||||
except:
|
||||
url_result = model_data.get("urlResult", {})
|
||||
if url_result:
|
||||
result["urlResult"] = {
|
||||
k: v for k, v in url_result.items()
|
||||
if v not in (None, "", {})
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
page.on("response", handle_response)
|
||||
@@ -147,12 +151,16 @@ def generate_3d(image_path, wait_for_complete=False, timeout=300):
|
||||
last_status = status
|
||||
|
||||
if status == "success":
|
||||
# 提取模型URL
|
||||
# 提取所有可用格式URL
|
||||
if "result" in status_result and len(status_result["result"]) > 0:
|
||||
model_data = status_result["result"][0]
|
||||
result["modelUrl"] = model_data.get("modelUrl")
|
||||
result["previewUrl"] = model_data.get("previewUrl")
|
||||
print(f"\n✅ 生成完成!")
|
||||
url_result = model_data.get("urlResult", {})
|
||||
if url_result:
|
||||
result["urlResult"] = {
|
||||
k: v for k, v in url_result.items()
|
||||
if v not in (None, "", {})
|
||||
}
|
||||
print(f"\n✅ 生成完成!可用格式: {', '.join(result['urlResult'].keys())}")
|
||||
break
|
||||
elif status == "fail":
|
||||
print(f"\n❌ 生成失败")
|
||||
|
||||
Reference in New Issue
Block a user