mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-07 04:03:45 +08:00
🧑💻 新增一部分安柏计划API
(#500)
This commit is contained in:
parent
4f21d66dec
commit
12e3e52faa
@ -4,7 +4,6 @@ from copy import deepcopy
|
||||
from typing import Dict, Literal
|
||||
|
||||
from httpx import AsyncClient
|
||||
|
||||
from gsuid_core.logger import logger
|
||||
|
||||
from ..utils.mys_api import mys_api
|
||||
|
@ -4,3 +4,7 @@ AMBR_WEAPON_URL = 'https://api.ambr.top/v2/CHS/weapon/{}?vh=32F6'
|
||||
AMBR_BOOK_URL = 'https://api.ambr.top/v2/chs/book?vh=34F5'
|
||||
AMBR_BOOK_DETAILS_URL = 'https://api.ambr.top/v2/CHS/book/{}?vh=34F5'
|
||||
AMBR_BOOK_DATA_URL = 'https://api.ambr.top/v2/CHS/readable/Book{}?vh=34F5'
|
||||
AMBR_MONSTER_URL = 'https://api.ambr.top/v2/chs/monster/{}?vh=37F4'
|
||||
AMBR_GCG_LIST_URL = 'https://api.ambr.top/v2/chs/gcg?vh=37F4'
|
||||
AMBR_GCG_DETAIL = 'https://api.ambr.top/v2/chs/gcg/{}?vh=37F4'
|
||||
AMBR_MONSTER_LIST = 'https://api.ambr.top/v2/chs/monster?vh=37F4'
|
||||
|
@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Dict, List, Literal, Optional, TypedDict
|
||||
from typing import Dict, List, Union, Literal, Optional, TypedDict, NotRequired
|
||||
|
||||
|
||||
class AmbrLanguageData(TypedDict):
|
||||
@ -163,3 +163,104 @@ class AmbrBookDetail(TypedDict):
|
||||
icon: str
|
||||
volume: List[AmbrVolume]
|
||||
route: str
|
||||
|
||||
|
||||
class AmbrMonsterAffix(TypedDict):
|
||||
name: str
|
||||
description: str
|
||||
abilityName: List[str]
|
||||
isCommon: bool
|
||||
|
||||
|
||||
class AmbrHpDrop(TypedDict):
|
||||
id: int
|
||||
hpPercent: int
|
||||
|
||||
|
||||
class AmbrReward(TypedDict):
|
||||
rank: int
|
||||
icon: str
|
||||
count: NotRequired[str]
|
||||
|
||||
|
||||
class AmbrEntry(TypedDict):
|
||||
id: str
|
||||
type: str
|
||||
affix: List[AmbrMonsterAffix]
|
||||
hpDrops: List[AmbrHpDrop]
|
||||
prop: List[AmbrProp]
|
||||
resistance: Dict[str, float]
|
||||
reward: Dict[str, AmbrReward]
|
||||
|
||||
|
||||
class AmbrMonster(TypedDict):
|
||||
id: int
|
||||
name: str
|
||||
icon: str
|
||||
route: str
|
||||
title: str
|
||||
specialName: str
|
||||
description: str
|
||||
entries: Dict[str, AmbrEntry]
|
||||
tips: Optional[str]
|
||||
|
||||
|
||||
class AmbrMonsterSimple(TypedDict):
|
||||
id: int
|
||||
name: str
|
||||
icon: str
|
||||
route: str
|
||||
type: str
|
||||
|
||||
|
||||
class AmbrGCGList(TypedDict):
|
||||
types: Dict[str, Literal['characterCard', 'actionCard']]
|
||||
items: Dict[str, AmbrGCGCard]
|
||||
|
||||
|
||||
class AmbrGCGCard(TypedDict):
|
||||
id: int
|
||||
name: str
|
||||
type: Literal['characterCard', 'actionCard']
|
||||
tags: Dict[str, str]
|
||||
props: Dict[str, int]
|
||||
icon: str
|
||||
route: str
|
||||
sortOrder: int
|
||||
|
||||
|
||||
class AmbrGCGDict(TypedDict):
|
||||
name: str
|
||||
description: str
|
||||
|
||||
|
||||
class AmbrGCGTalent(TypedDict):
|
||||
name: str
|
||||
description: str
|
||||
cost: Dict[str, int]
|
||||
params: Dict[str, Union[int, str]]
|
||||
tags: Dict[str, str]
|
||||
icon: str
|
||||
subSkills: Optional[str]
|
||||
keywords: Dict[str, str]
|
||||
|
||||
|
||||
class AmbrGCGEntry(TypedDict):
|
||||
id: int
|
||||
name: str
|
||||
type: Literal['gcg']
|
||||
icon: str
|
||||
|
||||
|
||||
class AmbrGCGDetail(AmbrGCGCard):
|
||||
storyTitle: str
|
||||
storyDetail: str
|
||||
source: str
|
||||
dictionary: Dict[str, AmbrGCGDict]
|
||||
talent: Dict[str, AmbrGCGTalent]
|
||||
relatedEntries: List[AmbrGCGCard]
|
||||
|
||||
|
||||
class AmbrMonsterList(TypedDict):
|
||||
types: Dict[str, str]
|
||||
items: Dict[str, AmbrMonsterSimple]
|
||||
|
@ -13,14 +13,22 @@ from .models import (
|
||||
AmbrBook,
|
||||
AmbrEvent,
|
||||
AmbrWeapon,
|
||||
AmbrGCGList,
|
||||
AmbrMonster,
|
||||
AmbrCharacter,
|
||||
AmbrGCGDetail,
|
||||
AmbrBookDetail,
|
||||
AmbrMonsterList,
|
||||
)
|
||||
from .api import (
|
||||
AMBR_BOOK_URL,
|
||||
AMBR_CHAR_URL,
|
||||
AMBR_EVENT_URL,
|
||||
AMBR_GCG_DETAIL,
|
||||
AMBR_WEAPON_URL,
|
||||
AMBR_MONSTER_URL,
|
||||
AMBR_GCG_LIST_URL,
|
||||
AMBR_MONSTER_LIST,
|
||||
AMBR_BOOK_DATA_URL,
|
||||
AMBR_BOOK_DETAILS_URL,
|
||||
)
|
||||
@ -43,6 +51,38 @@ async def get_ambr_char_data(id: Union[int, str]) -> Optional[AmbrCharacter]:
|
||||
return None
|
||||
|
||||
|
||||
async def get_ambr_monster_data(id: Union[int, str]) -> Optional[AmbrMonster]:
|
||||
data = await _ambr_request(url=AMBR_MONSTER_URL.format(id))
|
||||
if isinstance(data, Dict) and data['response'] == 200:
|
||||
data = data['data']
|
||||
return cast(AmbrMonster, data)
|
||||
return None
|
||||
|
||||
|
||||
async def get_ambr_gcg_detail(id: Union[int, str]) -> Optional[AmbrGCGDetail]:
|
||||
data = await _ambr_request(url=AMBR_GCG_DETAIL.format(id))
|
||||
if isinstance(data, Dict) and data['response'] == 200:
|
||||
data = data['data']
|
||||
return cast(AmbrGCGDetail, data)
|
||||
return None
|
||||
|
||||
|
||||
async def get_ambr_gcg_list() -> Optional[AmbrGCGList]:
|
||||
data = await _ambr_request(url=AMBR_GCG_LIST_URL)
|
||||
if isinstance(data, Dict) and data['response'] == 200:
|
||||
data = data['data']
|
||||
return cast(AmbrGCGList, data)
|
||||
return None
|
||||
|
||||
|
||||
async def get_ambr_monster_list() -> Optional[AmbrMonsterList]:
|
||||
data = await _ambr_request(url=AMBR_MONSTER_LIST)
|
||||
if isinstance(data, Dict) and data['response'] == 200:
|
||||
data = data['data']
|
||||
return cast(AmbrMonsterList, data)
|
||||
return None
|
||||
|
||||
|
||||
async def get_ambr_weapon_data(id: Union[int, str]) -> Optional[AmbrWeapon]:
|
||||
data = await _ambr_request(url=AMBR_WEAPON_URL.format(id))
|
||||
if isinstance(data, Dict) and data['response'] == 200:
|
||||
|
44
poetry.lock
generated
44
poetry.lock
generated
@ -349,32 +349,46 @@ lxml = ["lxml"]
|
||||
|
||||
[[package]]
|
||||
name = "black"
|
||||
version = "22.12.0"
|
||||
version = "23.3.0"
|
||||
description = "The uncompromising code formatter."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"},
|
||||
{file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"},
|
||||
{file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"},
|
||||
{file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"},
|
||||
{file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"},
|
||||
{file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"},
|
||||
{file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"},
|
||||
{file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"},
|
||||
{file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"},
|
||||
{file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"},
|
||||
{file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"},
|
||||
{file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"},
|
||||
{file = "black-23.3.0-cp310-cp310-macosx_10_16_arm64.whl", hash = "sha256:0945e13506be58bf7db93ee5853243eb368ace1c08a24c65ce108986eac65915"},
|
||||
{file = "black-23.3.0-cp310-cp310-macosx_10_16_universal2.whl", hash = "sha256:67de8d0c209eb5b330cce2469503de11bca4085880d62f1628bd9972cc3366b9"},
|
||||
{file = "black-23.3.0-cp310-cp310-macosx_10_16_x86_64.whl", hash = "sha256:7c3eb7cea23904399866c55826b31c1f55bbcd3890ce22ff70466b907b6775c2"},
|
||||
{file = "black-23.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:32daa9783106c28815d05b724238e30718f34155653d4d6e125dc7daec8e260c"},
|
||||
{file = "black-23.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:35d1381d7a22cc5b2be2f72c7dfdae4072a3336060635718cc7e1ede24221d6c"},
|
||||
{file = "black-23.3.0-cp311-cp311-macosx_10_16_arm64.whl", hash = "sha256:a8a968125d0a6a404842fa1bf0b349a568634f856aa08ffaff40ae0dfa52e7c6"},
|
||||
{file = "black-23.3.0-cp311-cp311-macosx_10_16_universal2.whl", hash = "sha256:c7ab5790333c448903c4b721b59c0d80b11fe5e9803d8703e84dcb8da56fec1b"},
|
||||
{file = "black-23.3.0-cp311-cp311-macosx_10_16_x86_64.whl", hash = "sha256:a6f6886c9869d4daae2d1715ce34a19bbc4b95006d20ed785ca00fa03cba312d"},
|
||||
{file = "black-23.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f3c333ea1dd6771b2d3777482429864f8e258899f6ff05826c3a4fcc5ce3f70"},
|
||||
{file = "black-23.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:11c410f71b876f961d1de77b9699ad19f939094c3a677323f43d7a29855fe326"},
|
||||
{file = "black-23.3.0-cp37-cp37m-macosx_10_16_x86_64.whl", hash = "sha256:1d06691f1eb8de91cd1b322f21e3bfc9efe0c7ca1f0e1eb1db44ea367dff656b"},
|
||||
{file = "black-23.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50cb33cac881766a5cd9913e10ff75b1e8eb71babf4c7104f2e9c52da1fb7de2"},
|
||||
{file = "black-23.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:e114420bf26b90d4b9daa597351337762b63039752bdf72bf361364c1aa05925"},
|
||||
{file = "black-23.3.0-cp38-cp38-macosx_10_16_arm64.whl", hash = "sha256:48f9d345675bb7fbc3dd85821b12487e1b9a75242028adad0333ce36ed2a6d27"},
|
||||
{file = "black-23.3.0-cp38-cp38-macosx_10_16_universal2.whl", hash = "sha256:714290490c18fb0126baa0fca0a54ee795f7502b44177e1ce7624ba1c00f2331"},
|
||||
{file = "black-23.3.0-cp38-cp38-macosx_10_16_x86_64.whl", hash = "sha256:064101748afa12ad2291c2b91c960be28b817c0c7eaa35bec09cc63aa56493c5"},
|
||||
{file = "black-23.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:562bd3a70495facf56814293149e51aa1be9931567474993c7942ff7d3533961"},
|
||||
{file = "black-23.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:e198cf27888ad6f4ff331ca1c48ffc038848ea9f031a3b40ba36aced7e22f2c8"},
|
||||
{file = "black-23.3.0-cp39-cp39-macosx_10_16_arm64.whl", hash = "sha256:3238f2aacf827d18d26db07524e44741233ae09a584273aa059066d644ca7b30"},
|
||||
{file = "black-23.3.0-cp39-cp39-macosx_10_16_universal2.whl", hash = "sha256:f0bd2f4a58d6666500542b26354978218a9babcdc972722f4bf90779524515f3"},
|
||||
{file = "black-23.3.0-cp39-cp39-macosx_10_16_x86_64.whl", hash = "sha256:92c543f6854c28a3c7f39f4d9b7694f9a6eb9d3c5e2ece488c327b6e7ea9b266"},
|
||||
{file = "black-23.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a150542a204124ed00683f0db1f5cf1c2aaaa9cc3495b7a3b5976fb136090ab"},
|
||||
{file = "black-23.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:6b39abdfb402002b8a7d030ccc85cf5afff64ee90fa4c5aebc531e3ad0175ddb"},
|
||||
{file = "black-23.3.0-py3-none-any.whl", hash = "sha256:ec751418022185b0c1bb7d7736e6933d40bbb14c14a0abcf9123d1b159f98dd4"},
|
||||
{file = "black-23.3.0.tar.gz", hash = "sha256:1c7b8d606e728a41ea1ccbd7264677e494e87cf630e399262ced92d4a8dac940"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
click = ">=8.0.0"
|
||||
mypy-extensions = ">=0.4.3"
|
||||
packaging = ">=22.0"
|
||||
pathspec = ">=0.9.0"
|
||||
platformdirs = ">=2"
|
||||
tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""}
|
||||
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
||||
typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""}
|
||||
|
||||
[package.extras]
|
||||
@ -2382,4 +2396,4 @@ multidict = ">=4.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.8.1"
|
||||
content-hash = "75de7e46ad78d2a8ec6a544d29a427b8080dd27c8da55c320115f9332b25c29f"
|
||||
content-hash = "2e3ac7bf6a9dba51107b72f2e154b12a89680385ec2d85a35c7a2e189e96320b"
|
||||
|
Loading…
x
Reference in New Issue
Block a user