From 8e68a43d6ae81ba8c946d4a55753c2c11c5dcabe Mon Sep 17 00:00:00 2001 From: KimigaiiWuyi <444835641@qq.com> Date: Sun, 8 Oct 2023 02:05:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=8A=A5=E9=94=99,=20=E7=A7=BB=E9=99=A4=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=96=87=E4=BB=B6,=20=E6=8F=90=E9=AB=98=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E4=B8=8B=E8=BD=BD=E5=BB=B6=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/resource/download_from_miniggicu.py | 13 +++++++++++-- GenshinUID/utils/resource/generate_char_card.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/GenshinUID/utils/resource/download_from_miniggicu.py b/GenshinUID/utils/resource/download_from_miniggicu.py index 140687f8..64988813 100644 --- a/GenshinUID/utils/resource/download_from_miniggicu.py +++ b/GenshinUID/utils/resource/download_from_miniggicu.py @@ -8,8 +8,9 @@ import aiohttp from bs4 import BeautifulSoup from aiohttp import TCPConnector from gsuid_core.logger import logger -from aiohttp.client import ClientSession +from aiohttp.client import ClientSession, ClientTimeout +from .RESOURCE_PATH import CHAR_PATH from .download_url import PATH_MAP, download_file # MINIGG_FILE = 'http://file.microgg.cn/KimigaiiWuyi/resource/' @@ -126,7 +127,10 @@ async def download_all_file_from_miniggicu(): failed_list: List[Tuple[str, int, str]] = [] TASKS = [] - async with ClientSession(connector=TCPConnector(verify_ssl=False)) as sess: + async with ClientSession( + connector=TCPConnector(verify_ssl=False), + timeout=ClientTimeout(total=None, sock_connect=20, sock_read=200), + ) as sess: for file in [ NAMECARD_FILE, SIDE_FILE, @@ -201,3 +205,8 @@ async def download_all_file_from_miniggicu(): await _download(TASKS) if count := len(failed_list): logger.error(f'{BASE_TAG}仍有{count}个文件未下载,请使用命令 `下载全部资源` 重新下载') + + for d_files in ['100000067.png', '100000068.png']: + path = CHAR_PATH / d_files + if path.exists(): + path.unlink() diff --git a/GenshinUID/utils/resource/generate_char_card.py b/GenshinUID/utils/resource/generate_char_card.py index 2dcf37f2..afc99b03 100644 --- a/GenshinUID/utils/resource/generate_char_card.py +++ b/GenshinUID/utils/resource/generate_char_card.py @@ -43,7 +43,7 @@ async def create_single_char_card(char_id: Union[str, int]) -> Image.Image: if not path.exists(): logger.warning(f'资源文件夹未发现图片{char_id}....忽略加载...') return Image.new('RGBA', (256, 310)) - char_img = Image.open(path) + char_img = Image.open(path).convert('RGBA') char_star = avatarId2Star_data[str(char_id)] char_frame = Image.open(texture2d_path / 'frame.png') char_bg = Image.open(texture2d_path / f'star{char_star}bg.png')