mirror of
https://github.com/hotyue/IP-Sentinel.git
synced 2026-09-04 23:18:17 +08:00
fix(scripts): 🐛 修复地图解析逻辑,深度穿透 JSON 锁定真实战区
This commit is contained in:
@@ -21,11 +21,16 @@ HEADERS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def get_active_regions():
|
def get_active_regions():
|
||||||
"""动态提取 map.json 中的战区"""
|
"""动态提取 map.json 中的战区 (修正:精准穿透 JSON 数组结构)"""
|
||||||
try:
|
try:
|
||||||
with open(MAP_JSON_PATH, 'r', encoding='utf-8') as f:
|
with open(MAP_JSON_PATH, 'r', encoding='utf-8') as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
return list(data.keys())
|
# 穿透到 countries 列表,提取所有的国家代码 (id)
|
||||||
|
regions = []
|
||||||
|
for country in data.get('countries', []):
|
||||||
|
if 'id' in country:
|
||||||
|
regions.append(country['id'])
|
||||||
|
return regions
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"❌ [读取地图失败]: {e}")
|
print(f"❌ [读取地图失败]: {e}")
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user