Spaces:
Running
Running
Download quanxue-src/scripts/quanxue/export_test.py from Ethscriptions/mx: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/Ethscriptions/mx/resolve/main/quanxue-src/scripts/quanxue/export_test.py
- Command line
-
hf download hf://spaces/Ethscriptions/mx/quanxue-src/scripts/quanxue/export_test.py
-
curl -L -o export_test.py https://huggingface.co/spaces/Ethscriptions/mx/resolve/main/quanxue-src/scripts/quanxue/export_test.py
1.03 kB
| """导出冒烟测试:python3 -I scripts/quanxue/export_test.py 720P,30,0,6,0,1 /tmp/out.mp4""" | |
| import asyncio, base64, sys | |
| from playwright.async_api import async_playwright | |
| arg, out = sys.argv[1], sys.argv[2] | |
| async def main(): | |
| async with async_playwright() as p: | |
| b = await p.chromium.launch(channel=sys.argv[3] if len(sys.argv) > 3 else None) | |
| pg = await b.new_page() | |
| pg.on("pageerror", lambda e: print("PAGEERR", e)) | |
| import os | |
| await pg.goto(os.environ.get("BASE", "http://localhost:5173/") + f"?exporttest={arg}") | |
| await pg.wait_for_function("window.__done === true", timeout=590000) | |
| st = (await pg.evaluate("window.__stats"))[0] | |
| print(st) | |
| if "bytes" in st: | |
| size = 4 * 1024 * 1024; data = bytearray() | |
| for i in range((st["bytes"] + size - 1) // size): | |
| data += base64.b64decode(await pg.evaluate(f"window.__chunk({i}, {size})")) | |
| open(out, "wb").write(data) | |
| await b.close() | |
| asyncio.run(main()) | |