2023-10-22 16:25:47 +00:00
|
|
|
from typing import List, Dict, Any
|
2023-02-28 14:15:48 +00:00
|
|
|
|
2023-10-07 15:15:30 +00:00
|
|
|
from httpx import AsyncClient
|
2023-02-28 14:15:48 +00:00
|
|
|
|
2023-10-07 15:15:30 +00:00
|
|
|
from metadata.scripts.metadatas import RESOURCE_FAST_URL, RESOURCE_FightPropRule_URL
|
|
|
|
from utils.log import logger
|
2023-02-28 14:15:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Remote:
|
|
|
|
"""拉取云控资源"""
|
|
|
|
|
2023-06-06 13:05:23 +00:00
|
|
|
BASE_URL = RESOURCE_FAST_URL
|
2023-02-28 14:15:48 +00:00
|
|
|
CALENDAR = f"{BASE_URL}calendar.json"
|
|
|
|
BIRTHDAY = f"{BASE_URL}birthday.json"
|
2023-04-04 14:02:14 +00:00
|
|
|
MATERIAL = f"{BASE_URL}roles_material.json"
|
2023-10-07 15:15:30 +00:00
|
|
|
RULE = f"{RESOURCE_FightPropRule_URL}FightPropRule_genshin.json"
|
2023-10-22 16:25:47 +00:00
|
|
|
DAMAGE = f"{RESOURCE_FightPropRule_URL}GenshinDamageRule.json"
|
2023-12-03 06:33:29 +00:00
|
|
|
GCSIM = f"{RESOURCE_FightPropRule_URL}gcsim.json"
|
2023-02-28 14:15:48 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def get_remote_calendar() -> Dict[str, Dict]:
|
|
|
|
"""获取云端日历"""
|
|
|
|
try:
|
|
|
|
async with AsyncClient() as client:
|
|
|
|
req = await client.get(Remote.CALENDAR)
|
|
|
|
if req.status_code == 200:
|
|
|
|
return req.json()
|
|
|
|
return {}
|
2023-10-22 16:25:47 +00:00
|
|
|
except Exception as exc: # skipcq: PYL-W0703
|
2023-10-07 15:15:30 +00:00
|
|
|
logger.error("获取云端日历失败: %s", exc_info=exc)
|
2023-02-28 14:15:48 +00:00
|
|
|
return {}
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def get_remote_birthday() -> Dict[str, List[str]]:
|
|
|
|
"""获取云端生日"""
|
|
|
|
try:
|
|
|
|
async with AsyncClient() as client:
|
|
|
|
req = await client.get(Remote.BIRTHDAY)
|
|
|
|
if req.status_code == 200:
|
|
|
|
return req.json()
|
|
|
|
return {}
|
2023-10-22 16:25:47 +00:00
|
|
|
except Exception as exc: # skipcq: PYL-W0703
|
2023-10-07 15:15:30 +00:00
|
|
|
logger.error("获取云端生日失败: %s", exc_info=exc)
|
2023-02-28 14:15:48 +00:00
|
|
|
return {}
|
2023-04-04 14:02:14 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def get_remote_material() -> Dict[str, List[str]]:
|
|
|
|
"""获取云端角色材料"""
|
|
|
|
try:
|
|
|
|
async with AsyncClient() as client:
|
|
|
|
req = await client.get(Remote.MATERIAL)
|
|
|
|
if req.status_code == 200:
|
|
|
|
return req.json()
|
|
|
|
return {}
|
2023-10-22 16:25:47 +00:00
|
|
|
except Exception as exc: # skipcq: PYL-W0703
|
2023-10-07 15:15:30 +00:00
|
|
|
logger.error("获取云端角色材料失败: %s", exc_info=exc)
|
|
|
|
return {}
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def get_fight_prop_rule_data() -> Dict[str, Dict[str, float]]:
|
|
|
|
"""获取云端圣遗物评分规则"""
|
|
|
|
try:
|
|
|
|
async with AsyncClient() as client:
|
|
|
|
req = await client.get(Remote.RULE)
|
|
|
|
if req.status_code == 200:
|
|
|
|
return req.json()
|
|
|
|
return {}
|
2023-10-22 16:25:47 +00:00
|
|
|
except Exception as exc: # skipcq: PYL-W0703
|
2023-10-07 15:15:30 +00:00
|
|
|
logger.error("获取云端圣遗物评分规则失败: %s", exc_info=exc)
|
2023-04-04 14:02:14 +00:00
|
|
|
return {}
|
2023-10-22 16:25:47 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def get_damage_data() -> Dict[str, Any]:
|
|
|
|
"""获取云端伤害计算规则"""
|
|
|
|
try:
|
|
|
|
async with AsyncClient() as client:
|
|
|
|
req = await client.get(Remote.DAMAGE)
|
|
|
|
if req.status_code == 200:
|
|
|
|
return req.json()
|
|
|
|
return {}
|
|
|
|
except Exception as exc: # skipcq: PYL-W0703
|
|
|
|
logger.error("获取云端伤害计算规则失败: %s", exc_info=exc)
|
|
|
|
return {}
|
2023-12-03 06:33:29 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def get_gcsim_scripts() -> Dict[str, str]:
|
|
|
|
"""获取云端 gcsim 脚本"""
|
|
|
|
try:
|
|
|
|
async with AsyncClient() as client:
|
|
|
|
req = await client.get(Remote.GCSIM)
|
|
|
|
if req.status_code == 200:
|
|
|
|
return req.json()
|
|
|
|
return {}
|
|
|
|
except Exception as exc: # skipcq: PYL-W0703
|
|
|
|
logger.error("获取云端 gcsim 脚本失败: %s", exc_info=exc)
|
|
|
|
return {}
|