mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-06 11:43:44 +08:00
add more hakush api
This commit is contained in:
parent
448787ea64
commit
1335f3fbed
@ -41,7 +41,7 @@ class HakushHsrCharacterSkill(Struct):
|
|||||||
Level: Dict[str, HakushHsrCharacterSkillLevel]
|
Level: Dict[str, HakushHsrCharacterSkillLevel]
|
||||||
|
|
||||||
|
|
||||||
class HakushHsrCharacterMaterial(Struct):
|
class HakushHsrMaterial(Struct):
|
||||||
ItemID: int
|
ItemID: int
|
||||||
ItemNum: int
|
ItemNum: int
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class HakushHsrCharacterSkillTree(Struct):
|
|||||||
DefaultUnlock: bool
|
DefaultUnlock: bool
|
||||||
Icon: str
|
Icon: str
|
||||||
LevelUpSkillID: List[int]
|
LevelUpSkillID: List[int]
|
||||||
MaterialList: List[Union[HakushHsrCharacterMaterial, None]]
|
MaterialList: List[Union[HakushHsrMaterial, None]]
|
||||||
MaxLevel: int
|
MaxLevel: int
|
||||||
ParamList: List[float]
|
ParamList: List[float]
|
||||||
PointID: int
|
PointID: int
|
||||||
@ -81,7 +81,7 @@ class HakushHsrCharacterStats(Struct):
|
|||||||
CriticalChance: float
|
CriticalChance: float
|
||||||
CriticalDamage: float
|
CriticalDamage: float
|
||||||
BaseAggro: float
|
BaseAggro: float
|
||||||
Cost: List[Union[HakushHsrCharacterMaterial, None]]
|
Cost: List[Union[HakushHsrMaterial, None]]
|
||||||
|
|
||||||
|
|
||||||
class HakushHsrCharacterRelicProperty(Struct):
|
class HakushHsrCharacterRelicProperty(Struct):
|
||||||
@ -110,3 +110,58 @@ class HakushHsrCharacter(Struct):
|
|||||||
SkillTrees: Dict[str, Dict[str, HakushHsrCharacterSkillTree]]
|
SkillTrees: Dict[str, Dict[str, HakushHsrCharacterSkillTree]]
|
||||||
Stats: Dict[str, HakushHsrCharacterStats]
|
Stats: Dict[str, HakushHsrCharacterStats]
|
||||||
Relics: HakushHsrCharacterRelic
|
Relics: HakushHsrCharacterRelic
|
||||||
|
|
||||||
|
|
||||||
|
class LightconeRefinementLevel(Struct):
|
||||||
|
ParamList: List[float]
|
||||||
|
|
||||||
|
|
||||||
|
class HakushHsrLightconeRefinement(Struct):
|
||||||
|
Desc: str
|
||||||
|
Level: Dict[str, LightconeRefinementLevel]
|
||||||
|
Name: str
|
||||||
|
|
||||||
|
|
||||||
|
class HakushHsrLightconeStat(Struct):
|
||||||
|
BaseAttack: float
|
||||||
|
BaseAttackAdd: float
|
||||||
|
BaseDefence: float
|
||||||
|
BaseDefenceAdd: float
|
||||||
|
BaseHP: float
|
||||||
|
BaseHPAdd: float
|
||||||
|
EquipmentID: int
|
||||||
|
MaxLevel: int
|
||||||
|
PromotionCostList: List[HakushHsrMaterial]
|
||||||
|
PlayerLevelRequire: Union[int, None] = None
|
||||||
|
WorldLevelRequire: Union[int, None] = None
|
||||||
|
|
||||||
|
|
||||||
|
class HakushHsrLightcone(Struct):
|
||||||
|
Name: str
|
||||||
|
Desc: str
|
||||||
|
Rarity: str
|
||||||
|
BaseType: str
|
||||||
|
Refinements: HakushHsrLightconeRefinement
|
||||||
|
Stats: List[HakushHsrLightconeStat]
|
||||||
|
|
||||||
|
|
||||||
|
class HakushHsrCharacterIndex(Struct):
|
||||||
|
icon: str
|
||||||
|
rank: str
|
||||||
|
baseType: str
|
||||||
|
damageType: str
|
||||||
|
en: str
|
||||||
|
desc: str
|
||||||
|
kr: str
|
||||||
|
cn: str
|
||||||
|
jp: str
|
||||||
|
|
||||||
|
|
||||||
|
class HakushHsrLightconeIndex(Struct):
|
||||||
|
rank: str
|
||||||
|
baseType: str
|
||||||
|
en: str
|
||||||
|
desc: str
|
||||||
|
kr: str
|
||||||
|
cn: str
|
||||||
|
jp: str
|
||||||
|
64
StarRailUID/sruid_utils/api/hakush/requests.py
Normal file
64
StarRailUID/sruid_utils/api/hakush/requests.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
from typing import Dict, Union
|
||||||
|
|
||||||
|
from httpx import AsyncClient
|
||||||
|
from msgspec import convert
|
||||||
|
|
||||||
|
from ..utils import _HEADER
|
||||||
|
from .model import (
|
||||||
|
HakushHsrCharacter,
|
||||||
|
HakushHsrCharacterIndex,
|
||||||
|
HakushHsrLightcone,
|
||||||
|
HakushHsrLightconeIndex,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def get_character_data(uid: str) -> Union[HakushHsrCharacter, None]:
|
||||||
|
async with AsyncClient(
|
||||||
|
base_url='https://api.hakush.in/hsr/data',
|
||||||
|
headers=_HEADER,
|
||||||
|
timeout=30,
|
||||||
|
) as client:
|
||||||
|
req = await client.get(f'/cn/character/{uid}.json')
|
||||||
|
if req.status_code == 200:
|
||||||
|
return convert(req.json(), type=HakushHsrCharacter)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
async def get_lightcone_data(uid: str) -> Union[HakushHsrLightcone, None]:
|
||||||
|
async with AsyncClient(
|
||||||
|
base_url='https://api.hakush.in/hsr/data',
|
||||||
|
headers=_HEADER,
|
||||||
|
timeout=30,
|
||||||
|
) as client:
|
||||||
|
req = await client.get(f'/cn/lightcone/{uid}.json')
|
||||||
|
if req.status_code == 200:
|
||||||
|
return convert(req.json(), type=HakushHsrLightcone)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
async def get_character_index() -> Union[
|
||||||
|
Dict[str, HakushHsrCharacterIndex], None
|
||||||
|
]:
|
||||||
|
async with AsyncClient(
|
||||||
|
base_url='https://api.hakush.in/hsr/data',
|
||||||
|
headers=_HEADER,
|
||||||
|
timeout=30,
|
||||||
|
) as client:
|
||||||
|
req = await client.get('/character.json')
|
||||||
|
if req.status_code == 200:
|
||||||
|
return convert(req.json(), type=Dict[str, HakushHsrCharacterIndex])
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
async def get_lightcone_index() -> Union[
|
||||||
|
Dict[str, HakushHsrLightconeIndex], None
|
||||||
|
]:
|
||||||
|
async with AsyncClient(
|
||||||
|
base_url='https://api.hakush.in/hsr/data',
|
||||||
|
headers=_HEADER,
|
||||||
|
timeout=30,
|
||||||
|
) as client:
|
||||||
|
req = await client.get('/character.json')
|
||||||
|
if req.status_code == 200:
|
||||||
|
return convert(req.json(), type=Dict[str, HakushHsrLightconeIndex])
|
||||||
|
return None
|
Loading…
x
Reference in New Issue
Block a user