🍱 更新基础资源, 提高加载速度
@ -1,12 +1,28 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
path = Path(__file__).parent
|
||||
with open(path / 'all_achi.json', "r", encoding='UTF-8') as f:
|
||||
all_achi = json.load(f)
|
||||
import aiofiles
|
||||
from gsuid_core.server import on_core_start
|
||||
|
||||
path = Path(__file__).parent
|
||||
all_achi = {}
|
||||
daily_achi = {}
|
||||
|
||||
|
||||
@on_core_start
|
||||
async def load_data():
|
||||
global all_achi, daily_achi
|
||||
|
||||
async with aiofiles.open(
|
||||
path / 'all_achi.json', "r", encoding='UTF-8'
|
||||
) as f:
|
||||
all_achi = json.loads(await f.read())
|
||||
|
||||
async with aiofiles.open(
|
||||
path / 'daily_achi.json', "r", encoding='UTF-8'
|
||||
) as f:
|
||||
daily_achi = json.loads(await f.read())
|
||||
|
||||
with open(path / 'daily_achi.json', "r", encoding='UTF-8') as f:
|
||||
daily_achi = json.load(f)
|
||||
|
||||
daily_template = '''任务:【{}】
|
||||
成就:【{}】
|
||||
|
@ -1,5 +1,6 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from PIL import Image, ImageOps, ImageDraw
|
||||
@ -18,13 +19,22 @@ from ..utils.image.image_tools import (
|
||||
|
||||
assets_dir = Path(__file__).parent / 'assets'
|
||||
|
||||
list_head = Image.open(assets_dir / 'list.png')
|
||||
list_item = (
|
||||
Image.open(assets_dir / 'item.png').resize((384, 96)).convert('RGBA')
|
||||
)
|
||||
list_head: Optional[Image.Image] = None
|
||||
list_item: Optional[Image.Image] = None
|
||||
|
||||
|
||||
async def ann_list_card() -> bytes:
|
||||
global list_head, list_item
|
||||
if not list_head:
|
||||
list_head = Image.open(assets_dir / 'list.png')
|
||||
|
||||
if not list_item:
|
||||
list_item = (
|
||||
Image.open(assets_dir / 'item.png')
|
||||
.resize((384, 96))
|
||||
.convert('RGBA')
|
||||
)
|
||||
|
||||
ann_list = await ann().get_ann_list()
|
||||
if not ann_list:
|
||||
raise Exception('获取游戏公告失败,请检查接口是否正常')
|
||||
@ -159,7 +169,7 @@ async def ann_detail_card(ann_id):
|
||||
bbox = gs_font_26.getbbox('囗')
|
||||
_x, _y = bbox[2] - bbox[0], bbox[3] - bbox[1]
|
||||
|
||||
padding = (_x, _y, _x, _y)
|
||||
padding = (int(_x), int(_y), int(_x), int(_y))
|
||||
im = ImageOps.expand(im, padding, '#f9f6f2')
|
||||
|
||||
return await convert_img(im)
|
||||
|
@ -14,17 +14,17 @@ yyy_data = {
|
||||
}
|
||||
'''
|
||||
|
||||
# 5.5影月月数据
|
||||
# 2025.3.27
|
||||
# 5.7影月月数据
|
||||
# 2025.5.18
|
||||
yyy_data = {
|
||||
'成就': 1458,
|
||||
'华丽的宝箱': 325,
|
||||
'珍贵的宝箱': 851,
|
||||
'精致的宝箱': 2714,
|
||||
'普通的宝箱': 3317,
|
||||
'精致的宝箱': 2717,
|
||||
'普通的宝箱': 3318,
|
||||
'奇馈宝箱': 316,
|
||||
'解锁传送点': 580,
|
||||
'解锁秘境': 63,
|
||||
'解锁传送点': 584,
|
||||
'解锁秘境': 64,
|
||||
}
|
||||
|
||||
# 影月月没收集到的数据
|
||||
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 505 KiB |
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 460 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.7 MiB |
@ -1,7 +1,5 @@
|
||||
import asyncio
|
||||
import threading
|
||||
|
||||
from gsuid_core.logger import logger
|
||||
from gsuid_core.server import on_core_start
|
||||
|
||||
from ..genshinuid_resource import startup
|
||||
|
||||
@ -11,12 +9,16 @@ from ..genshinuid_guide.get_new_abyss_data import download_Oceanid
|
||||
# from ..genshinuid_enka.start import check_artifacts_list
|
||||
# from ..genshinuid_guide.get_abyss_data import generate_data
|
||||
from ..utils.resource.generate_char_card import create_all_char_card
|
||||
|
||||
'''
|
||||
from ..genshinuid_xkdata.get_all_char_data import (
|
||||
save_all_char_info,
|
||||
save_all_abyss_rank,
|
||||
)
|
||||
'''
|
||||
|
||||
|
||||
@on_core_start
|
||||
async def all_start():
|
||||
try:
|
||||
await download_Oceanid()
|
||||
@ -25,10 +27,7 @@ async def all_start():
|
||||
await create_all_char_card()
|
||||
# await draw_teyvat_abyss_img()
|
||||
# await generate_data()
|
||||
await save_all_char_info()
|
||||
await save_all_abyss_rank()
|
||||
# await save_all_char_info()
|
||||
# await save_all_abyss_rank()
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
|
||||
threading.Thread(target=lambda: asyncio.run(all_start()), daemon=True).start()
|
||||
|
@ -134,5 +134,5 @@ def download_namecard_pic(start: int = 10000002):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# download_namecard_pic(10000063)
|
||||
main()
|
||||
download_namecard_pic(10000063)
|
||||
# main()
|
||||
|
@ -1,8 +1,10 @@
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, TypedDict
|
||||
|
||||
import aiofiles
|
||||
from msgspec import json as msgjson
|
||||
from gsuid_core.logger import logger
|
||||
from gsuid_core.server import on_core_start
|
||||
|
||||
from ...version import Genshin_version
|
||||
|
||||
@ -38,89 +40,194 @@ class TS(TypedDict):
|
||||
Icon: Dict[str, str]
|
||||
|
||||
|
||||
try:
|
||||
with open(MAP / charList_fileName, 'r', encoding='UTF-8') as f:
|
||||
charList = msgjson.decode(f.read(), type=Dict)
|
||||
charList: Dict[str, str] = {}
|
||||
weaponList: Dict[str, str] = {}
|
||||
avatarId2Name: Dict[str, str] = {}
|
||||
icon2Name: Dict[str, str] = {}
|
||||
artifact2attr: Dict[str, str] = {}
|
||||
name2Icon: Dict[str, str] = {}
|
||||
avatarName2Element: Dict[str, str] = {}
|
||||
avatarName2Weapon: Dict[str, str] = {}
|
||||
mysData: Dict = {}
|
||||
propId2Name: Dict[str, str] = {}
|
||||
Id2PropId: Dict[str, str] = {}
|
||||
artifactId2Piece: Dict[str, List[str]] = {}
|
||||
skillId2Name: TS = TS(Name={}, Icon={})
|
||||
talentId2Name: TS = TS(Name={}, Icon={})
|
||||
weaponHash2Name: Dict[str, str] = {}
|
||||
weaponHash2Type: Dict[str, str] = {}
|
||||
alias_data: Dict[str, List[str]] = {}
|
||||
avatarId2Star_data: Dict[str, str] = {}
|
||||
enName_to_avatarId_data: Dict[str, str] = {}
|
||||
ex_monster_data: Dict[str, Dict] = {}
|
||||
monster2entry_data: Dict[str, Dict] = {}
|
||||
avatarId2SkillList_data: Dict[str, Dict[str, str]] = {}
|
||||
weaponId2Name_data: Dict[str, str] = {}
|
||||
CharId2TalentIcon_data: Dict[str, List[str]] = {}
|
||||
|
||||
with open(MAP / weaponList_fileName, 'r', encoding='UTF-8') as f:
|
||||
weaponList = msgjson.decode(f.read(), type=Dict)
|
||||
|
||||
with open(MAP / avatarId2Name_fileName, 'r', encoding='UTF-8') as f:
|
||||
avatarId2Name = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
@on_core_start
|
||||
async def load_map():
|
||||
global charList, weaponList, avatarId2Name, icon2Name
|
||||
global artifact2attr, name2Icon, avatarName2Element
|
||||
global avatarName2Weapon, mysData, talentId2Name
|
||||
global propId2Name, Id2PropId, artifactId2Piece, skillId2Name
|
||||
global weaponHash2Name, weaponHash2Type, alias_data, avatarId2Star_data
|
||||
global enName_to_avatarId_data, ex_monster_data, monster2entry_data
|
||||
global avatarId2SkillList_data, weaponId2Name_data, CharId2TalentIcon_data
|
||||
logger.info('[GenshinUID MAP] 正在加载资源文件...')
|
||||
|
||||
with open(MAP / icon2Name_fileName, 'r', encoding='UTF-8') as f:
|
||||
icon2Name = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
try:
|
||||
async with aiofiles.open(
|
||||
MAP / charList_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
charList = msgjson.decode(await f.read(), type=Dict)
|
||||
|
||||
with open(MAP / artifact2attr_fileName, 'r', encoding='UTF-8') as f:
|
||||
artifact2attr = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / weaponList_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
weaponList = msgjson.decode(await f.read(), type=Dict)
|
||||
|
||||
with open(MAP / icon2Name_fileName, 'r', encoding='UTF-8') as f:
|
||||
icon2Name = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / avatarId2Name_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
avatarId2Name = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(MAP / name2Icon_fileName, 'r', encoding='UTF-8') as f:
|
||||
name2Icon = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / icon2Name_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
icon2Name = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(MAP / 'propId2Name_mapping.json', 'r', encoding='UTF-8') as f:
|
||||
propId2Name = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / artifact2attr_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
artifact2attr = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(MAP / 'Id2propId_mapping.json', 'r', encoding='UTF-8') as f:
|
||||
Id2PropId = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / icon2Name_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
icon2Name = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(MAP / weaponHash2Name_fileName, 'r', encoding='UTF-8') as f:
|
||||
weaponHash2Name = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / name2Icon_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
name2Icon = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(MAP / weaponHash2Type_fileName, 'r', encoding='UTF-8') as f:
|
||||
weaponHash2Type = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / 'propId2Name_mapping.json', 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
propId2Name = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(
|
||||
MAP / 'artifactId2Piece_mapping.json', 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
artifactId2Piece = msgjson.decode(f.read(), type=Dict[str, List[str]])
|
||||
async with aiofiles.open(
|
||||
MAP / 'Id2propId_mapping.json', 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
Id2PropId = msgjson.decode(await f.read(), type=Dict[str, str])
|
||||
|
||||
with open(MAP / skillId2Name_fileName, 'r', encoding='UTF-8') as f:
|
||||
skillId2Name = msgjson.decode(f.read(), type=TS)
|
||||
async with aiofiles.open(
|
||||
MAP / weaponHash2Name_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
weaponHash2Name = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
with open(MAP / talentId2Name_fileName, 'r', encoding='UTF-8') as f:
|
||||
talentId2Name = msgjson.decode(f.read(), type=TS)
|
||||
async with aiofiles.open(
|
||||
MAP / weaponHash2Type_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
weaponHash2Type = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
with open(MAP / avatarName2Element_fileName, 'r', encoding='UTF-8') as f:
|
||||
avatarName2Element = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / 'artifactId2Piece_mapping.json', 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
artifactId2Piece = msgjson.decode(
|
||||
await f.read(), type=Dict[str, List[str]]
|
||||
)
|
||||
|
||||
with open(MAP / avatarName2Weapon_fileName, 'r', encoding='UTF-8') as f:
|
||||
avatarName2Weapon = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / skillId2Name_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
skillId2Name = msgjson.decode(await f.read(), type=TS)
|
||||
|
||||
with open(MAP / 'char_alias.json', 'r', encoding='UTF-8') as f:
|
||||
alias_data = msgjson.decode(f.read(), type=Dict[str, List[str]])
|
||||
async with aiofiles.open(
|
||||
MAP / talentId2Name_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
talentId2Name = msgjson.decode(await f.read(), type=TS)
|
||||
|
||||
with open(MAP / avatarId2Star_fileName, 'r', encoding='utf8') as f:
|
||||
avatarId2Star_data = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / avatarName2Element_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
avatarName2Element = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
with open(MAP / avatarId2Star_fileName, 'r', encoding='utf8') as f:
|
||||
avatarId2Star_data = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / avatarName2Weapon_fileName, 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
avatarName2Weapon = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
with open(MAP / enName2Id_fileName, 'r', encoding='utf8') as f:
|
||||
enName_to_avatarId_data = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / 'char_alias.json', 'r', encoding='UTF-8'
|
||||
) as f:
|
||||
alias_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, List[str]]
|
||||
)
|
||||
|
||||
with open(MAP / EXMonster_fileName, 'r', encoding='utf8') as f:
|
||||
ex_monster_data = msgjson.decode(f.read(), type=Dict[str, Dict])
|
||||
async with aiofiles.open(
|
||||
MAP / avatarId2Star_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
avatarId2Star_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
with open(MAP / monster2entry_fileName, 'r', encoding='utf8') as f:
|
||||
monster2entry_data = msgjson.decode(f.read(), type=Dict[str, Dict])
|
||||
async with aiofiles.open(
|
||||
MAP / enName2Id_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
enName_to_avatarId_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
with open(MAP / avatarId2SkillList_fileName, 'r', encoding='utf8') as f:
|
||||
avatarId2SkillList_data = msgjson.decode(
|
||||
f.read(), type=Dict[str, Dict[str, str]]
|
||||
)
|
||||
async with aiofiles.open(
|
||||
MAP / EXMonster_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
ex_monster_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, Dict]
|
||||
)
|
||||
|
||||
with open(MAP / weaponId2Name_fileName, 'r', encoding='utf8') as f:
|
||||
weaponId2Name_data = msgjson.decode(f.read(), type=Dict[str, str])
|
||||
async with aiofiles.open(
|
||||
MAP / monster2entry_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
monster2entry_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, Dict]
|
||||
)
|
||||
|
||||
with open(MAP / mysData_fileName, 'r', encoding='utf8') as f:
|
||||
mysData = msgjson.decode(f.read(), type=Dict)
|
||||
async with aiofiles.open(
|
||||
MAP / avatarId2SkillList_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
avatarId2SkillList_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, Dict[str, str]]
|
||||
)
|
||||
|
||||
with open(MAP / CharId2TalentIcon_fileName, 'r', encoding='utf8') as f:
|
||||
CharId2TalentIcon_data = msgjson.decode(
|
||||
f.read(), type=Dict[str, List[str]]
|
||||
)
|
||||
except FileNotFoundError:
|
||||
logger.error('[GenshinUID] 未找到对应版本的映射文件')
|
||||
async with aiofiles.open(
|
||||
MAP / weaponId2Name_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
weaponId2Name_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, str]
|
||||
)
|
||||
|
||||
async with aiofiles.open(
|
||||
MAP / mysData_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
mysData = msgjson.decode(await f.read(), type=Dict)
|
||||
|
||||
async with aiofiles.open(
|
||||
MAP / CharId2TalentIcon_fileName, 'r', encoding='utf8'
|
||||
) as f:
|
||||
CharId2TalentIcon_data = msgjson.decode(
|
||||
await f.read(), type=Dict[str, List[str]]
|
||||
)
|
||||
logger.success('[GenshinUID MAP] 资源文件加载完成')
|
||||
except FileNotFoundError:
|
||||
logger.error('[GenshinUID] 未找到对应版本的映射文件')
|
||||
|
@ -1,11 +1,6 @@
|
||||
import asyncio
|
||||
|
||||
from .download_from_miniggicu import download_all_file_from_miniggicu
|
||||
|
||||
|
||||
async def download_all_resource():
|
||||
ret = await asyncio.gather(download_all_file_from_miniggicu())
|
||||
ret = [str(x) for x in ret if x]
|
||||
if ret:
|
||||
return '\n'.join(ret)
|
||||
await download_all_file_from_miniggicu()
|
||||
return 'Genshin全部资源下载完成!'
|
||||
|