mirror of
https://github.com/baiqwerdvd/StarRailUID.git
synced 2025-05-06 03:33:45 +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]
|
||||
|
||||
|
||||
class HakushHsrCharacterMaterial(Struct):
|
||||
class HakushHsrMaterial(Struct):
|
||||
ItemID: int
|
||||
ItemNum: int
|
||||
|
||||
@ -56,7 +56,7 @@ class HakushHsrCharacterSkillTree(Struct):
|
||||
DefaultUnlock: bool
|
||||
Icon: str
|
||||
LevelUpSkillID: List[int]
|
||||
MaterialList: List[Union[HakushHsrCharacterMaterial, None]]
|
||||
MaterialList: List[Union[HakushHsrMaterial, None]]
|
||||
MaxLevel: int
|
||||
ParamList: List[float]
|
||||
PointID: int
|
||||
@ -81,7 +81,7 @@ class HakushHsrCharacterStats(Struct):
|
||||
CriticalChance: float
|
||||
CriticalDamage: float
|
||||
BaseAggro: float
|
||||
Cost: List[Union[HakushHsrCharacterMaterial, None]]
|
||||
Cost: List[Union[HakushHsrMaterial, None]]
|
||||
|
||||
|
||||
class HakushHsrCharacterRelicProperty(Struct):
|
||||
@ -110,3 +110,58 @@ class HakushHsrCharacter(Struct):
|
||||
SkillTrees: Dict[str, Dict[str, HakushHsrCharacterSkillTree]]
|
||||
Stats: Dict[str, HakushHsrCharacterStats]
|
||||
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