mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
✨ 增加一部分安柏计划API
This commit is contained in:
parent
ebb9c225aa
commit
aa56b59943
@ -10,3 +10,5 @@ AMBR_GCG_DETAIL = 'https://api.ambr.top/v2/chs/gcg/{}?vh=37F4'
|
|||||||
AMBR_MONSTER_LIST = 'https://api.ambr.top/v2/chs/monster?vh=37F4'
|
AMBR_MONSTER_LIST = 'https://api.ambr.top/v2/chs/monster?vh=37F4'
|
||||||
AMBR_ICON_URL = 'https://api.ambr.top/assets/UI'
|
AMBR_ICON_URL = 'https://api.ambr.top/assets/UI'
|
||||||
AMBR_MONSTER_ICON_URL = f'{AMBR_ICON_URL}/monster/'
|
AMBR_MONSTER_ICON_URL = f'{AMBR_ICON_URL}/monster/'
|
||||||
|
AMBR_DAILY_URL = 'https://api.ambr.top/v2/chs/dailyDungeon?vh=37F4'
|
||||||
|
AMBR_UPGRADE_URL = 'https://api.ambr.top/v2/chs/upgrade?vh=40F3'
|
||||||
|
@ -264,3 +264,32 @@ class AmbrGCGDetail(AmbrGCGCard):
|
|||||||
class AmbrMonsterList(TypedDict):
|
class AmbrMonsterList(TypedDict):
|
||||||
types: Dict[str, str]
|
types: Dict[str, str]
|
||||||
items: Dict[str, AmbrMonsterSimple]
|
items: Dict[str, AmbrMonsterSimple]
|
||||||
|
|
||||||
|
|
||||||
|
class AmbrDungeon(TypedDict):
|
||||||
|
id: int
|
||||||
|
name: str
|
||||||
|
reward: List[int]
|
||||||
|
city: int
|
||||||
|
|
||||||
|
|
||||||
|
class AmbrDaily(TypedDict):
|
||||||
|
monday: List[AmbrDungeon]
|
||||||
|
tuesday: List[AmbrDungeon]
|
||||||
|
tuesday: List[AmbrDungeon]
|
||||||
|
thursday: List[AmbrDungeon]
|
||||||
|
friday: List[AmbrDungeon]
|
||||||
|
saturday: List[AmbrDungeon]
|
||||||
|
sunday: List[AmbrDungeon]
|
||||||
|
|
||||||
|
|
||||||
|
class AmbrUpgradeOne(TypedDict):
|
||||||
|
name: str
|
||||||
|
rank: int
|
||||||
|
icon: str
|
||||||
|
items: Dict[str, int]
|
||||||
|
|
||||||
|
|
||||||
|
class AmbrUpgradeItem(TypedDict):
|
||||||
|
avatar: Dict[str, AmbrUpgradeOne]
|
||||||
|
weapon: Dict[str, AmbrUpgradeOne]
|
||||||
|
@ -15,6 +15,7 @@ from ..types import AnyDict
|
|||||||
from ..utils import _HEADER
|
from ..utils import _HEADER
|
||||||
from .models import (
|
from .models import (
|
||||||
AmbrBook,
|
AmbrBook,
|
||||||
|
AmbrDaily,
|
||||||
AmbrEvent,
|
AmbrEvent,
|
||||||
AmbrWeapon,
|
AmbrWeapon,
|
||||||
AmbrGCGList,
|
AmbrGCGList,
|
||||||
@ -23,15 +24,18 @@ from .models import (
|
|||||||
AmbrGCGDetail,
|
AmbrGCGDetail,
|
||||||
AmbrBookDetail,
|
AmbrBookDetail,
|
||||||
AmbrMonsterList,
|
AmbrMonsterList,
|
||||||
|
AmbrUpgradeItem,
|
||||||
)
|
)
|
||||||
from .api import (
|
from .api import (
|
||||||
AMBR_BOOK_URL,
|
AMBR_BOOK_URL,
|
||||||
AMBR_CHAR_URL,
|
AMBR_CHAR_URL,
|
||||||
AMBR_ICON_URL,
|
AMBR_ICON_URL,
|
||||||
|
AMBR_DAILY_URL,
|
||||||
AMBR_EVENT_URL,
|
AMBR_EVENT_URL,
|
||||||
AMBR_GCG_DETAIL,
|
AMBR_GCG_DETAIL,
|
||||||
AMBR_WEAPON_URL,
|
AMBR_WEAPON_URL,
|
||||||
AMBR_MONSTER_URL,
|
AMBR_MONSTER_URL,
|
||||||
|
AMBR_UPGRADE_URL,
|
||||||
AMBR_GCG_LIST_URL,
|
AMBR_GCG_LIST_URL,
|
||||||
AMBR_MONSTER_LIST,
|
AMBR_MONSTER_LIST,
|
||||||
AMBR_BOOK_DATA_URL,
|
AMBR_BOOK_DATA_URL,
|
||||||
@ -94,6 +98,25 @@ async def get_ambr_weapon_data(id: Union[int, str]) -> Optional[AmbrWeapon]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
async def get_ambr_daily_data() -> Optional[AmbrDaily]:
|
||||||
|
data = await _ambr_request(url=AMBR_DAILY_URL)
|
||||||
|
if isinstance(data, Dict) and data['response'] == 200:
|
||||||
|
data = data['data']
|
||||||
|
insert = {}
|
||||||
|
for day in data:
|
||||||
|
insert[day] = [value for value in data[day].values()]
|
||||||
|
return cast(AmbrDaily, insert)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
async def get_all_upgrade() -> Optional[AmbrUpgradeItem]:
|
||||||
|
data = await _ambr_request(url=AMBR_UPGRADE_URL)
|
||||||
|
if isinstance(data, Dict) and data['response'] == 200:
|
||||||
|
data = data['data']
|
||||||
|
return cast(AmbrUpgradeItem, data)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def get_all_book_id() -> Optional[Dict[str, AmbrBook]]:
|
async def get_all_book_id() -> Optional[Dict[str, AmbrBook]]:
|
||||||
data = await _ambr_request(url=AMBR_BOOK_URL)
|
data = await _ambr_request(url=AMBR_BOOK_URL)
|
||||||
if isinstance(data, Dict) and data['response'] == 200:
|
if isinstance(data, Dict) and data['response'] == 200:
|
||||||
@ -117,8 +140,32 @@ async def get_story_data(story_id: Union[int, str]) -> Optional[str]:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
async def get_ambr_icon(type: str, icon_name: str, path: Path) -> Image.Image:
|
async def get_ambr_icon(
|
||||||
file_path = path / f'{icon_name}.png'
|
type: str,
|
||||||
|
icon_name: str,
|
||||||
|
path: Path,
|
||||||
|
ui_name: str,
|
||||||
|
save_name: Optional[str] = None,
|
||||||
|
) -> Image.Image:
|
||||||
|
'''
|
||||||
|
获取ItemIcon:
|
||||||
|
await get_ambr_icon('UI', '114004', path, 'ItemIcon')
|
||||||
|
https://api.ambr.top/assets/UI/UI_ItemIcon_114004.png
|
||||||
|
获取其他:
|
||||||
|
await get_ambr_icon('UI', 'Chongyun', path, 'AvatarIcon')
|
||||||
|
https://api.ambr.top/assets/UI/UI_AvatarIcon_Chongyun.png
|
||||||
|
'''
|
||||||
|
if ui_name:
|
||||||
|
item_icon = f'UI_{ui_name}_{icon_name}.png'
|
||||||
|
url = f'{AMBR_ICON_URL}/{item_icon}'
|
||||||
|
else:
|
||||||
|
item_icon = f'{icon_name}.png'
|
||||||
|
url = f'{AMBR_ICON_URL}/{type}/{item_icon}'
|
||||||
|
|
||||||
|
if save_name:
|
||||||
|
item_icon = f'{save_name}.png'
|
||||||
|
|
||||||
|
file_path = path / item_icon
|
||||||
|
|
||||||
if file_path.exists():
|
if file_path.exists():
|
||||||
async with aiofiles.open(file_path, 'rb') as f:
|
async with aiofiles.open(file_path, 'rb') as f:
|
||||||
@ -126,7 +173,7 @@ async def get_ambr_icon(type: str, icon_name: str, path: Path) -> Image.Image:
|
|||||||
|
|
||||||
async with AsyncClient(timeout=None) as client:
|
async with AsyncClient(timeout=None) as client:
|
||||||
req = await client.get(
|
req = await client.get(
|
||||||
f'{AMBR_ICON_URL}/{type}/{icon_name}.png',
|
url,
|
||||||
headers=_HEADER,
|
headers=_HEADER,
|
||||||
)
|
)
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
|
6
poetry.lock
generated
6
poetry.lock
generated
@ -1105,13 +1105,13 @@ reference = "mirrors"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "identify"
|
name = "identify"
|
||||||
version = "2.5.26"
|
version = "2.5.27"
|
||||||
description = "File identification library for Python"
|
description = "File identification library for Python"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
files = [
|
files = [
|
||||||
{file = "identify-2.5.26-py2.py3-none-any.whl", hash = "sha256:c22a8ead0d4ca11f1edd6c9418c3220669b3b7533ada0a0ffa6cc0ef85cf9b54"},
|
{file = "identify-2.5.27-py2.py3-none-any.whl", hash = "sha256:fdb527b2dfe24602809b2201e033c2a113d7bdf716db3ca8e3243f735dcecaba"},
|
||||||
{file = "identify-2.5.26.tar.gz", hash = "sha256:7243800bce2f58404ed41b7c002e53d4d22bcf3ae1b7900c2d7aefd95394bf7f"},
|
{file = "identify-2.5.27.tar.gz", hash = "sha256:287b75b04a0e22d727bc9a41f0d4f3c1bcada97490fa6eabb5b28f0e9097e733"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user