Spaces:
Running
Running
File size: 1,029 Bytes
7b4250a ff955d4 7b4250a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | """导出冒烟测试: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())
|