feat: add on-demand format conversion support (FBX, STL, USDZ, MP4, GIF)
- Discover /creations/resourceConvert endpoint via browser inspection - Add resource_convert() method to api.py and api_complete.py - Extend MODEL_FORMAT_KEYS with fbx, stl, usdz, mp4, gif - Update get_model_urls() and download_model() with include_converted flag - Update CLI with --converted flag for formats and download commands - Update reverse engineering docs with native vs converted format tables
This commit is contained in:
+7
-2
@@ -33,6 +33,8 @@ def main():
|
||||
|
||||
formats_parser = subparsers.add_parser("formats", help="列出创作可用下载格式")
|
||||
formats_parser.add_argument("creation_id", help="创作ID")
|
||||
formats_parser.add_argument("--converted", action="store_true",
|
||||
help="包含转换格式 (fbx/stl/usdz/mp4/gif)")
|
||||
formats_parser.add_argument("--cookies", "-c", default=_DEFAULT_COOKIE, help="Cookie文件路径")
|
||||
|
||||
download_parser = subparsers.add_parser("download", help="下载指定格式模型")
|
||||
@@ -41,6 +43,8 @@ def main():
|
||||
help="格式键名 (默认: glb)")
|
||||
download_parser.add_argument("--output", "-o", default=None,
|
||||
help="本地保存路径 (默认自动推断)")
|
||||
download_parser.add_argument("--converted", action="store_true",
|
||||
help="若格式为转换格式,自动调用转换接口")
|
||||
download_parser.add_argument("--cookies", "-c", default=_DEFAULT_COOKIE, help="Cookie文件路径")
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -62,14 +66,15 @@ def main():
|
||||
elif args.command == "status":
|
||||
print(json.dumps(api.get_generation_status(args.creation_id), indent=2, ensure_ascii=False))
|
||||
elif args.command == "formats":
|
||||
urls = api.get_model_urls(args.creation_id)
|
||||
urls = api.get_model_urls(args.creation_id, include_converted=args.converted)
|
||||
if not urls:
|
||||
print("暂无可用格式,可能生成未完成或失败。", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
for key, url in urls.items():
|
||||
print(f"{key}: {url}")
|
||||
elif args.command == "download":
|
||||
path = api.download_model(args.creation_id, args.format, args.output)
|
||||
path = api.download_model(args.creation_id, args.format, args.output,
|
||||
include_converted=args.converted)
|
||||
print(f"已下载: {path}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user