mirror of
https://github.com/PaiGramTeam/genshin-wiki.git
synced 2024-11-21 22:58:02 +00:00
🐛 fix some bugs
This commit is contained in:
parent
fa5c315d67
commit
6de4b1a553
@ -150,13 +150,20 @@ class Association(StrEnum):
|
|||||||
"""稻妻"""
|
"""稻妻"""
|
||||||
Mondstadt = "MONDSTADT"
|
Mondstadt = "MONDSTADT"
|
||||||
"""蒙德"""
|
"""蒙德"""
|
||||||
Mainactor = "MAINACTOR"
|
|
||||||
"""主角"""
|
|
||||||
Liyue = "LIYUE"
|
Liyue = "LIYUE"
|
||||||
"""璃月"""
|
"""璃月"""
|
||||||
|
Sumeru = "SUMERU"
|
||||||
|
"""须弥"""
|
||||||
|
Fontaine = "FONTAINE"
|
||||||
|
"""枫丹"""
|
||||||
|
Natlan = "NATLAN"
|
||||||
|
"""纳塔"""
|
||||||
|
Snezhnaya = "SNEZHNAYA"
|
||||||
|
"""至冬"""
|
||||||
|
|
||||||
|
Mainactor = "MAINACTOR"
|
||||||
|
"""主角"""
|
||||||
Fatui = "FATUI"
|
Fatui = "FATUI"
|
||||||
"""愚人众"""
|
"""愚人众"""
|
||||||
Ranger = "RANGER"
|
Ranger = "RANGER"
|
||||||
"""游侠"""
|
"""游侠"""
|
||||||
Sumeru = "SUMERU"
|
|
||||||
"""须弥"""
|
|
||||||
|
@ -22,8 +22,10 @@ class Item(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class Material(Item):
|
class Material(Item):
|
||||||
material_type: MaterialType
|
material_type: str
|
||||||
"""材料类型"""
|
"""材料类型"""
|
||||||
|
material_type_description: str
|
||||||
|
"""材料类型描述"""
|
||||||
|
|
||||||
|
|
||||||
class Food(Item):
|
class Food(Item):
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from functools import lru_cache
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
@ -46,79 +47,6 @@ TalentType = TypeVar("TalentType", bound=Talent)
|
|||||||
|
|
||||||
OUT_DIR = PROJECT_ROOT.joinpath("out")
|
OUT_DIR = PROJECT_ROOT.joinpath("out")
|
||||||
|
|
||||||
elements_map = {
|
|
||||||
(
|
|
||||||
230082676,
|
|
||||||
313529204,
|
|
||||||
627825788,
|
|
||||||
1247335084,
|
|
||||||
1646245548,
|
|
||||||
1740638908,
|
|
||||||
3105283268,
|
|
||||||
3112476852,
|
|
||||||
3177381772,
|
|
||||||
3847511308,
|
|
||||||
): Element.Pyro,
|
|
||||||
(
|
|
||||||
321258364,
|
|
||||||
483165900,
|
|
||||||
756679372,
|
|
||||||
1688473500,
|
|
||||||
2480954540,
|
|
||||||
3228108484,
|
|
||||||
3400532572,
|
|
||||||
3646588372,
|
|
||||||
4022324356,
|
|
||||||
): Element.Hydro,
|
|
||||||
(
|
|
||||||
126875444,
|
|
||||||
467004516,
|
|
||||||
550531300,
|
|
||||||
898621369,
|
|
||||||
1778251796,
|
|
||||||
2075460644,
|
|
||||||
2477900860,
|
|
||||||
2648184060,
|
|
||||||
): Element.Anemo,
|
|
||||||
(
|
|
||||||
122554396,
|
|
||||||
608089036,
|
|
||||||
689445588,
|
|
||||||
1072755468,
|
|
||||||
1821644548,
|
|
||||||
1843086100,
|
|
||||||
2085306033,
|
|
||||||
2143937940,
|
|
||||||
2480172868,
|
|
||||||
2689029804,
|
|
||||||
3352621156,
|
|
||||||
4219874220,
|
|
||||||
): Element.Electro,
|
|
||||||
(2161032364, 4017448612): Element.Dendro,
|
|
||||||
(
|
|
||||||
98482612,
|
|
||||||
766902996,
|
|
||||||
862088588,
|
|
||||||
1480674860,
|
|
||||||
1695600284,
|
|
||||||
2778487532,
|
|
||||||
2809830820,
|
|
||||||
3057990932,
|
|
||||||
4127670180,
|
|
||||||
4220569804,
|
|
||||||
): Element.Cryo,
|
|
||||||
(
|
|
||||||
825986772,
|
|
||||||
967031460,
|
|
||||||
1016213980,
|
|
||||||
1662907292,
|
|
||||||
2507042785,
|
|
||||||
3219124204,
|
|
||||||
3617274620,
|
|
||||||
3929787020,
|
|
||||||
): Element.Geo,
|
|
||||||
(471154292, 821712868, 1128382182, 3053155130, 4168416172): Element.Null,
|
|
||||||
}
|
|
||||||
prop_type_map = {
|
prop_type_map = {
|
||||||
"Hp": PropType.HP,
|
"Hp": PropType.HP,
|
||||||
"RockAddHurt": PropType.Geo,
|
"RockAddHurt": PropType.Geo,
|
||||||
@ -240,6 +168,42 @@ def parse_passive_talent(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@lru_cache
|
||||||
|
def get_element_data() -> dict[Element, set[int]]:
|
||||||
|
_manager = ResourceManager("chs")
|
||||||
|
_avatar_json_data = _manager.fetch("AvatarExcelConfigData")
|
||||||
|
_fetter_info_json_data = manager.fetch("FetterInfoExcelConfigData")
|
||||||
|
text_map = {
|
||||||
|
"火": Element.Pyro,
|
||||||
|
"水": Element.Hydro,
|
||||||
|
"风": Element.Anemo,
|
||||||
|
"雷": Element.Electro,
|
||||||
|
"草": Element.Dendro,
|
||||||
|
"冰": Element.Cryo,
|
||||||
|
"岩": Element.Geo,
|
||||||
|
"无": Element.Null,
|
||||||
|
}
|
||||||
|
result = {k: set() for k in text_map.values()}
|
||||||
|
for data in _avatar_json_data:
|
||||||
|
_id = data["id"]
|
||||||
|
if (
|
||||||
|
info_data := next(
|
||||||
|
chain(
|
||||||
|
filter(lambda x: x["avatarId"] == _id, _fetter_info_json_data),
|
||||||
|
[None],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) is None:
|
||||||
|
continue
|
||||||
|
if (
|
||||||
|
vision := _manager.get_text(
|
||||||
|
text_id := info_data["avatarVisionBeforTextMapHash"]
|
||||||
|
)
|
||||||
|
) is not None:
|
||||||
|
result[text_map[vision]] = set(list(result[text_map[vision]]) + [text_id])
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyShadowingBuiltins,SpellCheckingInspection,PyGlobalUndefined
|
# noinspection PyShadowingBuiltins,SpellCheckingInspection,PyGlobalUndefined
|
||||||
async def parse_avatar_data(lang: Lang):
|
async def parse_avatar_data(lang: Lang):
|
||||||
global out_path, manager
|
global out_path, manager
|
||||||
@ -259,6 +223,8 @@ async def parse_avatar_data(lang: Lang):
|
|||||||
proud_skill_json_data = manager.fetch("ProudSkillExcelConfigData")
|
proud_skill_json_data = manager.fetch("ProudSkillExcelConfigData")
|
||||||
talent_json_data = manager.fetch("AvatarTalentExcelConfigData")
|
talent_json_data = manager.fetch("AvatarTalentExcelConfigData")
|
||||||
|
|
||||||
|
element_data = get_element_data()
|
||||||
|
|
||||||
avatar_list = []
|
avatar_list = []
|
||||||
for data in avatar_json_data:
|
for data in avatar_json_data:
|
||||||
id = data["id"]
|
id = data["id"]
|
||||||
@ -273,10 +239,10 @@ async def parse_avatar_data(lang: Lang):
|
|||||||
name = manager.get_text(data["nameTextMapHash"])
|
name = manager.get_text(data["nameTextMapHash"])
|
||||||
element = next(
|
element = next(
|
||||||
filter(
|
filter(
|
||||||
lambda x: info_data["avatarVisionBeforTextMapHash"] in x[0],
|
lambda x: info_data["avatarVisionBeforTextMapHash"] in x[1],
|
||||||
elements_map.items(),
|
element_data.items(),
|
||||||
)
|
)
|
||||||
)[1]
|
)[0]
|
||||||
quality = AvatarQuality(
|
quality = AvatarQuality(
|
||||||
data["qualityType"].removeprefix("QUALITY_").replace("ORANGE_SP", "SPECIAL")
|
data["qualityType"].removeprefix("QUALITY_").replace("ORANGE_SP", "SPECIAL")
|
||||||
)
|
)
|
||||||
|
@ -51,10 +51,19 @@ async def parse_item_data(
|
|||||||
item = Namecard(pictures=pictures, **kwargs)
|
item = Namecard(pictures=pictures, **kwargs)
|
||||||
|
|
||||||
elif "materialType" in data:
|
elif "materialType" in data:
|
||||||
material_type = MaterialType(
|
# material_type = MaterialType(
|
||||||
data["materialType"].removeprefix("MATERIAL_")
|
# data["materialType"].removeprefix("MATERIAL_")
|
||||||
|
# )
|
||||||
|
# item = Material(material_type=material_type, **kwargs)
|
||||||
|
material_type = data["materialType"].removeprefix("MATERIAL_")
|
||||||
|
item = Material(
|
||||||
|
material_type=material_type,
|
||||||
|
material_type_description=manager.get_text(
|
||||||
|
data["typeDescTextMapHash"]
|
||||||
|
)
|
||||||
|
or "",
|
||||||
|
**kwargs,
|
||||||
)
|
)
|
||||||
item = Material(material_type=material_type, **kwargs)
|
|
||||||
elif "foodQuality" in data:
|
elif "foodQuality" in data:
|
||||||
quality = FoodQuality(data["foodQuality"])
|
quality = FoodQuality(data["foodQuality"])
|
||||||
effect = manager.get_text(data["effectDescTextMapHash"])
|
effect = manager.get_text(data["effectDescTextMapHash"])
|
||||||
|
@ -24,8 +24,7 @@ class ResourceManager:
|
|||||||
|
|
||||||
def __init__(self, base_url: str | None = None, lang: Lang | None = None):
|
def __init__(self, base_url: str | None = None, lang: Lang | None = None):
|
||||||
self._base_url = URL(
|
self._base_url = URL(
|
||||||
base_url
|
base_url or "https://gitlab.com/Dimbreath/AnimeGameData/-/raw/master/"
|
||||||
or "https://git.neeemooo.com/githubbackup/GenshinData/-/raw/master/"
|
|
||||||
)
|
)
|
||||||
self._lang = lang or "chs"
|
self._lang = lang or "chs"
|
||||||
|
|
||||||
@ -35,8 +34,10 @@ class ResourceManager:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def client(self) -> Client:
|
def client(self) -> Client:
|
||||||
|
from httpx import Timeout
|
||||||
|
|
||||||
if self._client is None or self._client.is_closed:
|
if self._client is None or self._client.is_closed:
|
||||||
self._client = Client(verify=ssl_context)
|
self._client = Client(verify=ssl_context, timeout=Timeout(timeout=30))
|
||||||
return self._client
|
return self._client
|
||||||
|
|
||||||
def refresh(self) -> None:
|
def refresh(self) -> None:
|
||||||
@ -65,8 +66,10 @@ class ResourceManager:
|
|||||||
file_path = DATA_DIR.joinpath(file_dir).joinpath(name).with_suffix(".json")
|
file_path = DATA_DIR.joinpath(file_dir).joinpath(name).with_suffix(".json")
|
||||||
file_path.parent.mkdir(exist_ok=True, parents=True)
|
file_path.parent.mkdir(exist_ok=True, parents=True)
|
||||||
|
|
||||||
if not file_path.exists() or os.stat(file_path) == 0:
|
if not (file_path.exists() and os.stat(file_path)):
|
||||||
response = self.client.get(str(self._base_url / file_dir / file_path.name))
|
response = self.client.get(
|
||||||
|
str(self._base_url / file_dir / file_path.name)
|
||||||
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
with open(file_path, encoding="utf-8", mode="w") as file:
|
with open(file_path, encoding="utf-8", mode="w") as file:
|
||||||
file.write(content := response.text)
|
file.write(content := response.text)
|
||||||
|
Loading…
Reference in New Issue
Block a user