#!/usr/bin/env python3
# # -*- coding: utf-8 -*-

import sys
from playwright.sync_api import sync_playwright

sys.path.append("../../convert/31-0")
from db import *

db.bind(provider="sqlite", filename="../../clean/31-0/data.sqlite3")
db.generate_mapping()

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(device_scale_factor=3)
    with db_session:
        for m in Melee.select():
            print(f"rendering {m.name}...")
            page.goto(f"http://localhost:8080/{m.name}")
            page.locator(".container").screenshot(path=f"./output/{m.name}.png")
    browser.close()
