🐛 Fix the failure to obtain map information

Co-authored-by: xtaodada <xtao@xtaolink.cn>
This commit is contained in:
luoshuijs 2023-06-06 17:51:38 +08:00 committed by GitHub
parent 36a61e9986
commit 1201a5faf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,9 +22,9 @@ class MapHelper:
"""提瓦特大地图"""
MAP_API_URL = "https://map.minigg.cn/map/get_map"
LABEL_URL = "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/map/label/tree?app_sn=ys_obc"
COUNT_URL = "https://api-static.mihoyo.com/common/blackboard/ys_obc/v1/map/point/list"
COUNT_PARAMS = {"app_sn": "ys_obc", "map_id": "2"}
LABEL_URL = "https://api-takumi.mihoyo.com/common/map_user/ys_obc/v1/map/label/tree"
COUNT_URL = "https://api-takumi.mihoyo.com/common/map_user/ys_obc/v1/map/point/list"
COUNT_PARAMS = {"app_sn": "ys_obc", "map_id": "2", "lang": "zh-cn"}
MAP_ID_LIST = [
"2",
"7",
@ -64,11 +64,14 @@ class MapHelper:
async def refresh_query_map(self) -> None:
"""刷新查询映射"""
data = {}
label_data = await self.client.get(self.LABEL_URL)
for label_tree_source in label_data.json().get("data", {}).get("tree", []):
label_tree = LabelTree(**label_tree_source)
for child in label_tree.children:
data[child.name] = str(child.id)
for map_id in self.MAP_ID_LIST:
params = self.COUNT_PARAMS.copy()
params["map_id"] = map_id
label_data = await self.client.get(self.LABEL_URL, params=params)
for label_tree_source in label_data.json().get("data", {}).get("tree", []):
label_tree = LabelTree(**label_tree_source)
for child in label_tree.children:
data[child.name] = str(child.id)
self.query_map = data
self.save(data, self.query_map_path)