From dc1c0f0d24d009c199b64964f663ca91ed47b1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98KimigaiiWuyi=E2=80=99?= <444835641@qq.com> Date: Tue, 7 May 2024 20:19:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20=E4=BF=AE=E5=A4=8D=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenshinUID/tools/data_to_map.py | 3 ++ GenshinUID/tools/download_icon.py | 66 +++++++++++++++++----------- GenshinUID/utils/hakush_to_minigg.py | 9 ++++ 3 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 GenshinUID/utils/hakush_to_minigg.py diff --git a/GenshinUID/tools/data_to_map.py b/GenshinUID/tools/data_to_map.py index 9575eceb..7fbb82a8 100644 --- a/GenshinUID/tools/data_to_map.py +++ b/GenshinUID/tools/data_to_map.py @@ -66,6 +66,9 @@ '10000091': '娜维娅', '10000092': '嘉明', '10000093': '闲云', + '10000095': '希格雯', + '10000097': '赛索斯', + '10000098': '克洛琳德', } diff --git a/GenshinUID/tools/download_icon.py b/GenshinUID/tools/download_icon.py index 40729a9f..e47431ba 100644 --- a/GenshinUID/tools/download_icon.py +++ b/GenshinUID/tools/download_icon.py @@ -1,42 +1,51 @@ import json +from io import BytesIO from typing import Dict from pathlib import Path import httpx +from PIL import Image MAP_PATH = Path(__file__).parent.parent / 'utils' / 'map' / 'data' -with open(MAP_PATH / 'enName2AvatarID_mapping_4.5.0.json') as f: +with open(MAP_PATH / 'enName2AvatarID_mapping_4.6.0.json') as f: enmap: Dict[str, str] = json.load(f) -char_list = ['Arlecchino'] -base = 'https://api.ambr.top/assets/UI' +suffix = 'webp' + +char_list = ['Sigewinne', 'Sethos', 'Clorinde'] +base = 'https://api.hakush.in/gi/UI/' # title = 'https://enka.network/ui/{}' +# hakush = 'https://api.hakush.in/gi/UI/' +# ambr = 'https://api.ambr.top/assets/UI' + + icon_list = [ - 'Skill_E_{}_01.png', - 'Skill_E_{}_02.png', - 'Skill_S_{}_01.png', - 'Skill_S_{}_02.png', - 'UI_Talent_S_{}_01.png', - 'UI_Talent_S_{}_02.png', - 'UI_Talent_S_{}_03.png', - 'UI_Talent_S_{}_04.png', - 'UI_Talent_S_{}_05.png', - 'UI_Talent_S_{}_06.png', - 'UI_Talent_S_{}_07.png', - 'UI_Talent_U_{}_01.png', - 'UI_Talent_U_{}_02.png', - 'UI_Talent_C_{}_01.png', - 'UI_Talent_C_{}_02.png', - 'UI_Gacha_AvatarImg_{}.png', - 'UI_NameCardIcon_{}.png', - 'UI_AvatarIcon_{}.png', - 'UI_NameCardPic_{}_P.png', + 'Skill_E_{}_01.' + suffix, + 'Skill_E_{}_02.' + suffix, + 'Skill_S_{}_01.' + suffix, + 'Skill_S_{}_02.' + suffix, + 'UI_Talent_S_{}_01.' + suffix, + 'UI_Talent_S_{}_02.' + suffix, + 'UI_Talent_S_{}_03.' + suffix, + 'UI_Talent_S_{}_04.' + suffix, + 'UI_Talent_S_{}_05.' + suffix, + 'UI_Talent_S_{}_06.' + suffix, + 'UI_Talent_S_{}_07.' + suffix, + 'UI_Talent_U_{}_01.' + suffix, + 'UI_Talent_U_{}_02.' + suffix, + 'UI_Talent_C_{}_01.' + suffix, + 'UI_Talent_C_{}_02.' + suffix, + 'UI_Gacha_AvatarImg_{}.' + suffix, + 'UI_NameCardIcon_{}.' + suffix, + 'UI_AvatarIcon_{}.' + suffix, + 'UI_NameCardPic_{}_P.' + suffix, ] is_download = True def download(icon_name: str, url: str): + icon_name = icon_name.split('.')[0] + '.png' path = Path(__file__).parent / icon_name if path.exists(): print(f'{icon_name}已经存在!,跳过!') @@ -45,10 +54,17 @@ def download(icon_name: str, url: str): char_data = httpx.get(url, follow_redirects=True, timeout=80) if char_data.headers['Content-Type'] == 'image/png': char_bytes = char_data.content + elif char_data.headers['Content-Type'] == 'image/webp': + webp_image = BytesIO(char_data.content) + img = Image.open(webp_image) + png_bytes = BytesIO() + img.save(png_bytes, 'PNG') + png_bytes.seek(0) + char_bytes = png_bytes.read() else: print(f'{icon_name}不存在,跳过!') return - # img_data = httpx.get(url).content + with open(path, '+wb') as handler: handler.write(char_bytes) print('下载成功!') @@ -102,8 +118,8 @@ def download_namecard_pic(): en = 'Hutao' elif en == 'Thoma': en = 'Tohma' - url = f'{base}/namecard/UI_NameCardPic_{en}_P.png' - download(f'{avatar_id}.png', url) + url = f'{base}/namecard/UI_NameCardPic_{en}_P.' + suffix + download(f'{avatar_id}.' + suffix, url) # download_namecard_pic() diff --git a/GenshinUID/utils/hakush_to_minigg.py b/GenshinUID/utils/hakush_to_minigg.py new file mode 100644 index 00000000..16d3aca7 --- /dev/null +++ b/GenshinUID/utils/hakush_to_minigg.py @@ -0,0 +1,9 @@ +from typing import Union, Optional + +from .ambr_to_minigg import ConvertWeapon + + +async def convert_hakush_to_weapon( + weapon_id: Union[int, str] +) -> Optional[ConvertWeapon]: + return None