add auto download chromium

This commit is contained in:
felinae98 2021-10-18 14:50:54 +08:00
parent ad6836680f
commit b2ce29f6a9
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610

View File

@ -1,6 +1,7 @@
import asyncio
import base64
from html import escape
import os
from time import asctime
from typing import Awaitable, Callable, Optional
@ -8,6 +9,7 @@ from nonebot.adapters.cqhttp.message import MessageSegment
from nonebot.log import logger
from pyppeteer import connect, launch
from pyppeteer.browser import Browser
from pyppeteer.chromium_downloader import check_chromium, download_chromium
from pyppeteer.page import Page
from .plugin_config import plugin_config
@ -19,6 +21,10 @@ class Singleton(type):
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
return cls._instances[cls]
if not plugin_config.hk_reporter_browser and not plugin_config.hk_reporter_use_local \
and not check_chromium():
os.environ['PYPPETEER_DOWNLOAD_HOST'] = 'http://npm.taobao.org/mirrors'
download_chromium()
class Render(metaclass=Singleton):