mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-08 04:55:51 +08:00
🍱 更新3.8版本规划
, 修复mr
, 填充资源
This commit is contained in:
parent
6eacb7f904
commit
52b6bdbbc5
37
GenshinUID/genshinuid_enka/start.py
Normal file
37
GenshinUID/genshinuid_enka/start.py
Normal file
@ -0,0 +1,37 @@
|
||||
import re
|
||||
import json
|
||||
from copy import deepcopy
|
||||
|
||||
import aiofiles
|
||||
from gsuid_core.logger import logger
|
||||
|
||||
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH
|
||||
from .to_data import ARTIFACT_DATA, input_artifacts_data
|
||||
|
||||
|
||||
async def check_artifacts_list():
|
||||
pattern = r'^[\u4e00-\u9fa5]'
|
||||
logger.info('开始检查是否创建圣遗物列表...')
|
||||
for player in PLAYER_PATH.iterdir():
|
||||
path = player / 'artifacts.json'
|
||||
all_artifacts = deepcopy(ARTIFACT_DATA)
|
||||
if not path.exists():
|
||||
logger.info(f'UID{player.name} 不存在圣遗物列表,开始生成中...')
|
||||
for char in player.iterdir():
|
||||
match = re.match(pattern, char.name)
|
||||
if match:
|
||||
async with aiofiles.open(
|
||||
char, 'r', encoding='UTF-8'
|
||||
) as file:
|
||||
char_data = json.loads(await file.read())
|
||||
|
||||
for artifact in char_data['equipList']:
|
||||
all_artifacts = await input_artifacts_data(
|
||||
artifact, all_artifacts, char_data['avatarId']
|
||||
)
|
||||
# 保存原始数据
|
||||
async with aiofiles.open(path, 'w', encoding='UTF-8') as file:
|
||||
await file.write(
|
||||
json.dumps(all_artifacts, indent=4, ensure_ascii=False)
|
||||
)
|
||||
logger.info('圣遗物列表检查完成!')
|
@ -1,7 +1,9 @@
|
||||
import json
|
||||
import time
|
||||
from typing import List, Union, Literal, Optional
|
||||
from copy import deepcopy
|
||||
from typing import Dict, List, Union, Literal, Optional
|
||||
|
||||
import aiofiles
|
||||
from httpx import ReadTimeout, ConnectTimeout
|
||||
from gsuid_core.utils.error_reply import UID_HINT
|
||||
from gsuid_core.utils.api.enka.models import EnkaData
|
||||
@ -34,6 +36,22 @@ PROP_ATTR_MAP = {
|
||||
}
|
||||
|
||||
ENKA_API: List[Literal['enka', 'microgg']] = ['enka', 'microgg']
|
||||
ARTIFACT_DATA = {
|
||||
'data': {
|
||||
'flower': [],
|
||||
'plume': [],
|
||||
'sands': [],
|
||||
'goblet': [],
|
||||
'circlet': [],
|
||||
},
|
||||
'tag': {
|
||||
'flower': [],
|
||||
'plume': [],
|
||||
'sands': [],
|
||||
'goblet': [],
|
||||
'circlet': [],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
async def switch_api():
|
||||
@ -83,17 +101,34 @@ async def enka_to_dict(
|
||||
playerInfo = enka_data['playerInfo']
|
||||
path = PLAYER_PATH / str(uid)
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
with open(
|
||||
path / '{}.json'.format(str(uid)), 'w', encoding='UTF-8'
|
||||
|
||||
# 保存基本玩家信息
|
||||
async with aiofiles.open(
|
||||
path / f'{uid}.json', 'w', encoding='UTF-8'
|
||||
) as file:
|
||||
json.dump(playerInfo, file, ensure_ascii=False)
|
||||
with open(path / 'rawData.json', 'w', encoding='UTF-8') as file:
|
||||
json.dump(enka_data, file, ensure_ascii=False)
|
||||
await file.write(json.dumps(playerInfo, indent=4, ensure_ascii=False))
|
||||
|
||||
# 保存原始数据
|
||||
async with aiofiles.open(
|
||||
path / 'rawData.json', 'w', encoding='UTF-8'
|
||||
) as file:
|
||||
await file.write(json.dumps(enka_data, indent=4, ensure_ascii=False))
|
||||
|
||||
if 'avatarInfoList' not in enka_data:
|
||||
return f'UID{uid}刷新失败!未打开角色展柜!'
|
||||
|
||||
char_dict_list = []
|
||||
|
||||
# 确认是否存在圣遗物列表
|
||||
all_artifacts_path = path / 'artifacts.json'
|
||||
if not all_artifacts_path.exists():
|
||||
all_artifacts_data = deepcopy(ARTIFACT_DATA)
|
||||
else:
|
||||
async with aiofiles.open(
|
||||
all_artifacts_path, 'r', encoding='UTF-8'
|
||||
) as file:
|
||||
all_artifacts_data = json.loads(await file.read())
|
||||
|
||||
for char in enka_data['avatarInfoList']:
|
||||
# 处理基本信息
|
||||
char_data = {}
|
||||
@ -278,6 +313,7 @@ async def enka_to_dict(
|
||||
artifacts_info = []
|
||||
artifacts_data = char['equipList'][:-1]
|
||||
artifact_set_list = []
|
||||
|
||||
for artifact in artifacts_data:
|
||||
artifact_temp = {}
|
||||
artifact_temp['itemId'] = artifact['itemId']
|
||||
@ -295,6 +331,7 @@ async def enka_to_dict(
|
||||
artifact_temp['aritifactSetPiece'] = artifactId2Piece[
|
||||
artifact_temp['icon'].split('_')[-1]
|
||||
][0]
|
||||
|
||||
artifact_temp['aritifactPieceName'] = artifactId2Piece[
|
||||
artifact_temp['icon'].split('_')[-1]
|
||||
][1]
|
||||
@ -319,8 +356,22 @@ async def enka_to_dict(
|
||||
artifact_temp['reliquarySubstats'] = []
|
||||
for sub in artifact_temp['reliquarySubstats']:
|
||||
sub['statName'] = propId2Name[sub['appendPropId']]
|
||||
|
||||
await input_artifacts_data(
|
||||
artifact_temp, all_artifacts_data, avatarId
|
||||
)
|
||||
|
||||
# 加入单个圣遗物部件
|
||||
artifacts_info.append(artifact_temp)
|
||||
|
||||
# 保存原始数据
|
||||
async with aiofiles.open(
|
||||
path / 'artifacts.json', 'w', encoding='UTF-8'
|
||||
) as file:
|
||||
await file.write(
|
||||
json.dumps(all_artifacts_data, indent=4, ensure_ascii=False)
|
||||
)
|
||||
|
||||
equipSetList = set(artifact_set_list)
|
||||
char_data['equipSets'] = {'type': '', 'set': ''}
|
||||
char_data['equipList'] = artifacts_info
|
||||
@ -339,10 +390,13 @@ async def enka_to_dict(
|
||||
char_data['equipSets']['set'] = char_data['equipSets']['set'][1:]
|
||||
|
||||
char_dict_list.append(char_data)
|
||||
with open(
|
||||
async with aiofiles.open(
|
||||
path / '{}.json'.format(avatarName), 'w', encoding='UTF-8'
|
||||
) as file:
|
||||
json.dump(char_data, file, ensure_ascii=False)
|
||||
await file.write(
|
||||
json.dumps(char_data, indent=4, ensure_ascii=False)
|
||||
)
|
||||
|
||||
return char_dict_list
|
||||
|
||||
|
||||
@ -358,3 +412,33 @@ async def enka_to_data(
|
||||
char_name_list.append(char_data['avatarName'])
|
||||
char_name_list_str = ','.join(char_name_list)
|
||||
return f'UID{uid}刷新完成!\n本次缓存:{char_name_list_str}'
|
||||
|
||||
|
||||
async def input_artifacts_data(
|
||||
artifact_temp: Dict, all_artifacts_data: Dict, avatarId: int
|
||||
):
|
||||
# 加入圣遗物数据列表
|
||||
if (
|
||||
artifact_temp
|
||||
not in all_artifacts_data['data'][artifact_temp['aritifactSetPiece']]
|
||||
):
|
||||
all_artifacts_data['data'][artifact_temp['aritifactSetPiece']].append(
|
||||
artifact_temp
|
||||
)
|
||||
all_artifacts_data['tag'][artifact_temp['aritifactSetPiece']].append(
|
||||
[avatarId]
|
||||
)
|
||||
elif (
|
||||
avatarId
|
||||
not in all_artifacts_data['tag'][artifact_temp['aritifactSetPiece']][
|
||||
all_artifacts_data['data'][
|
||||
artifact_temp['aritifactSetPiece']
|
||||
].index(artifact_temp)
|
||||
]
|
||||
):
|
||||
all_artifacts_data['tag'][artifact_temp['aritifactSetPiece']][
|
||||
all_artifacts_data['data'][
|
||||
artifact_temp['aritifactSetPiece']
|
||||
].index(artifact_temp)
|
||||
].append(avatarId)
|
||||
return all_artifacts_data
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 513 KiB |
BIN
GenshinUID/genshinuid_etcimg/primogems_data/3.8.png
Normal file
BIN
GenshinUID/genshinuid_etcimg/primogems_data/3.8.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 496 KiB |
@ -14,10 +14,10 @@ from ..utils.api.mys.models import FakeResin
|
||||
from ..utils.image.convert import convert_img
|
||||
from ..genshinuid_config.gs_config import gsconfig
|
||||
from ..genshinuid_enka.to_data import get_enka_info
|
||||
from ..utils.map.name_covert import enName_to_avatarId
|
||||
from ..utils.resource.download_url import download_file
|
||||
from ..utils.api.mys.models import Expedition as WidgetExpedition
|
||||
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH, CHAR_SIDE_PATH
|
||||
from ..utils.api.mys.models import Transformer, WidgetResin, RecoveryTime
|
||||
from ..utils.resource.RESOURCE_PATH import PLAYER_PATH, CHAR_SIDE_TEMP_PATH
|
||||
from ..utils.fonts.genshin_fonts import (
|
||||
gs_font_20,
|
||||
gs_font_26,
|
||||
@ -49,10 +49,17 @@ async def _draw_task_img(
|
||||
if not char['avatar_side_icon']:
|
||||
return go_img
|
||||
|
||||
char_en_name = char['avatar_side_icon'].split('_')[-1].split('.')[0]
|
||||
avatar_id = await enName_to_avatarId(char_en_name)
|
||||
char_temp = char['avatar_side_icon'].split('/')[-1]
|
||||
side_path = CHAR_SIDE_TEMP_PATH / char_temp
|
||||
if not side_path.exists():
|
||||
await download_file(
|
||||
char['avatar_side_icon'],
|
||||
13,
|
||||
char_temp,
|
||||
)
|
||||
# avatar_id = await enName_to_avatarId(char_en_name)
|
||||
char_pic = (
|
||||
Image.open(CHAR_SIDE_PATH / f'{avatar_id}.png')
|
||||
Image.open(side_path)
|
||||
.convert('RGBA')
|
||||
.resize((115, 115), Image.Resampling.LANCZOS) # type: ignore
|
||||
)
|
||||
|
@ -6,6 +6,7 @@ from gsuid_core.logger import logger
|
||||
from ..utils.database import get_sqla
|
||||
from ..genshinuid_resource import startup
|
||||
from ..genshinuid_xkdata import draw_xk_abyss_img
|
||||
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 (
|
||||
@ -18,6 +19,7 @@ async def all_start():
|
||||
try:
|
||||
get_sqla('TEMP')
|
||||
await startup()
|
||||
await check_artifacts_list()
|
||||
await create_all_char_card()
|
||||
await draw_xk_abyss_img()
|
||||
await generate_data()
|
||||
|
@ -44,7 +44,7 @@ async def get_pic(url, size: Optional[Tuple[int, int]] = None) -> Image.Image:
|
||||
pic = Image.open(BytesIO(resp.read()))
|
||||
pic = pic.convert("RGBA")
|
||||
if size is not None:
|
||||
pic = pic.resize(size, Image.LANCZOS)
|
||||
pic = pic.resize(size, Image.Resampling.LANCZOS)
|
||||
return pic
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ GACHA_IMG_PATH = RESOURCE_PATH / 'gacha_img'
|
||||
CHAR_PATH = RESOURCE_PATH / 'chars'
|
||||
CHAR_STAND_PATH = RESOURCE_PATH / 'char_stand'
|
||||
CHAR_SIDE_PATH = RESOURCE_PATH / 'char_side'
|
||||
CHAR_SIDE_TEMP_PATH = RESOURCE_PATH / 'char_side_temp'
|
||||
CHAR_CARD_PATH = RESOURCE_PATH / 'char_card'
|
||||
CHAR_NAMECARD_PATH = RESOURCE_PATH / 'char_namecard'
|
||||
REL_PATH = RESOURCE_PATH / 'reliquaries'
|
||||
@ -69,6 +70,7 @@ def init_dir():
|
||||
WIKI_COST_CHAR_PATH,
|
||||
WIKI_COST_WEAPON_PATH,
|
||||
DATA_PATH,
|
||||
CHAR_SIDE_TEMP_PATH,
|
||||
]:
|
||||
i.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
@ -18,6 +18,7 @@ from .RESOURCE_PATH import (
|
||||
GACHA_IMG_PATH,
|
||||
CHAR_STAND_PATH,
|
||||
CHAR_NAMECARD_PATH,
|
||||
CHAR_SIDE_TEMP_PATH,
|
||||
)
|
||||
|
||||
PATH_MAP = {
|
||||
@ -33,6 +34,7 @@ PATH_MAP = {
|
||||
10: GUIDE_PATH,
|
||||
11: WIKI_PATH,
|
||||
12: REF_PATH,
|
||||
13: CHAR_SIDE_TEMP_PATH,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user