mirror of
https://github.com/PaiGramTeam/HonkaiStarRailWikiDataParser.git
synced 2025-01-30 18:38:36 +00:00
✨ support: square icon
This commit is contained in:
parent
faf212844b
commit
6a1333ebb5
@ -27,6 +27,7 @@ async def fetch_avatars(data: Children):
|
||||
avatar = Avatar(
|
||||
id=content.content_id,
|
||||
name=content.title,
|
||||
icon=content.icon,
|
||||
quality=m_quality,
|
||||
element=m_element,
|
||||
destiny=m_destiny,
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import List
|
||||
from pydantic import BaseModel
|
||||
from models.enums import Quality, Destiny, Element
|
||||
from models.material import Material
|
||||
from .enums import Quality, Destiny, Element
|
||||
from .material import Material
|
||||
|
||||
|
||||
class AvatarInfo(BaseModel):
|
||||
@ -44,6 +44,8 @@ class Avatar(BaseModel):
|
||||
"""角色ID"""
|
||||
name: str
|
||||
"""名称"""
|
||||
icon: str
|
||||
"""图标"""
|
||||
quality: Quality
|
||||
"""品质"""
|
||||
destiny: Destiny
|
||||
|
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
@ -22,3 +22,19 @@ class AvatarIcon(BaseModel):
|
||||
"""名称"""
|
||||
icon: List[str]
|
||||
"""图标(从小到大)"""
|
||||
|
||||
@property
|
||||
def gacha(self) -> str:
|
||||
return self.icon[3]
|
||||
|
||||
@property
|
||||
def icon_(self) -> str:
|
||||
return self.icon[0]
|
||||
|
||||
@property
|
||||
def square(self) -> Optional[str]:
|
||||
return self.icon[1]
|
||||
|
||||
@property
|
||||
def normal(self) -> str:
|
||||
return self.icon[2]
|
||||
|
@ -1,8 +1,8 @@
|
||||
# 光锥
|
||||
from pydantic import BaseModel
|
||||
|
||||
from models.enums import Quality, Destiny
|
||||
from models.material import Material
|
||||
from .enums import Quality, Destiny
|
||||
from .material import Material
|
||||
|
||||
|
||||
class LightConeItem(BaseModel):
|
||||
|
@ -10,3 +10,11 @@ class LightConeIcon(BaseModel):
|
||||
"""名称"""
|
||||
icon: List[str]
|
||||
"""图标(从小到大)"""
|
||||
|
||||
@property
|
||||
def gacha(self) -> str:
|
||||
return self.icon[1]
|
||||
|
||||
@property
|
||||
def icon_(self) -> str:
|
||||
return self.icon[0]
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 材料
|
||||
from pydantic import BaseModel
|
||||
|
||||
from models.enums import Quality, MaterialType
|
||||
from .enums import Quality, MaterialType
|
||||
|
||||
|
||||
class Material(BaseModel):
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 敌对物种
|
||||
from pydantic import BaseModel
|
||||
|
||||
from models.enums import MonsterType, Area
|
||||
from .enums import MonsterType, Area
|
||||
|
||||
|
||||
class Monster(BaseModel):
|
||||
|
@ -28,18 +28,21 @@ async def fetch_config(text_map: Dict[str, str]) -> List[AvatarConfig]:
|
||||
return datas
|
||||
|
||||
|
||||
async def parse_station(datas, tag: Tag, avatar: AvatarConfig):
|
||||
second_pic = f'{base_station_url}{tag.find("img").get("src")}'
|
||||
async def parse_station(datas, name: str, tag: Tag, avatar: AvatarConfig):
|
||||
second_pic = ""
|
||||
if avatar_model := all_avatars_name.get(name):
|
||||
second_pic = avatar_model.icon
|
||||
third_pic = f'{base_station_url}{tag.find("img").get("src")}'
|
||||
html = await client.get(f'{base_station_url}{tag.get("href")}')
|
||||
soup = BeautifulSoup(html.text, "lxml")
|
||||
text = soup.find("div", {"class": "a6678 a4af5"}).get("style")
|
||||
third_pic = f'{base_station_url}{text[text.find("(") + 2:text.find(")") - 1]}' if text else ""
|
||||
four_pic = f'{base_station_url}{text[text.find("(") + 2:text.find(")") - 1]}' if text else ""
|
||||
first_pic = f'{base_station_url}{soup.find("img", {"class": "ac39b a6602"}).get("src")}'
|
||||
datas.append(
|
||||
AvatarIcon(
|
||||
id=avatar.AvatarID,
|
||||
name=avatar.name,
|
||||
icon=[first_pic, second_pic, third_pic],
|
||||
icon=[first_pic, second_pic, third_pic, four_pic],
|
||||
)
|
||||
)
|
||||
|
||||
@ -64,7 +67,7 @@ async def fetch_station(configs_map: Dict[str, AvatarConfig]) -> List[AvatarIcon
|
||||
if name == "开拓者" and ktz:
|
||||
continue
|
||||
if avatar_model := configs_map.get(name):
|
||||
tasks.append(parse_station(datas, avatar, avatar_model))
|
||||
tasks.append(parse_station(datas, name, avatar, avatar_model))
|
||||
if name == "开拓者":
|
||||
ktz = True
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user