This commit is contained in:
felinae98 2021-12-08 12:07:43 +08:00
parent cc64cb5035
commit b10af53d8b
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610

View File

@ -2,18 +2,17 @@ import asyncio
import base64 import base64
from html import escape from html import escape
import os import os
from time import asctime
import re import re
import subprocess
from time import asctime
from typing import Awaitable, Callable, Optional from typing import Awaitable, Callable, Optional
from bs4 import BeautifulSoup as bs
import nonebot
from nonebot.adapters.cqhttp.message import MessageSegment from nonebot.adapters.cqhttp.message import MessageSegment
from nonebot.log import logger from nonebot.log import logger
import subprocess
from playwright.async_api import async_playwright, Browser, Page
from playwright._impl._driver import compute_driver_executable from playwright._impl._driver import compute_driver_executable
from playwright.async_api import Browser, Page, async_playwright
from bs4 import BeautifulSoup as bs
from .plugin_config import plugin_config from .plugin_config import plugin_config
@ -24,11 +23,14 @@ class Singleton(type):
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs) cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls] return cls._instances[cls]
if not plugin_config.bison_browser and not plugin_config.bison_use_local: @nonebot.get_driver().on_startup
env = os.environ.copy() def download_browser():
driver_executable = compute_driver_executable() if not plugin_config.bison_browser and not plugin_config.bison_use_local:
env["PW_CLI_TARGET_LANG"] = "python" env = os.environ.copy()
subprocess.run([str(driver_executable), "install", "chromium"], env=env) driver_executable = compute_driver_executable()
env["PW_CLI_TARGET_LANG"] = "python"
subprocess.run([str(driver_executable), "install", "chromium"], env=env)
class Render(metaclass=Singleton): class Render(metaclass=Singleton):