| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- """Parse the srvlist response to find the full server structure."""
- import asyncio
- import httpx
- import json
- import sys
- import os
- sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, "src"))
- from cq2_sdk.env_loader import load_env
- load_env()
- async def main():
- gameid = os.environ.get("CQ2_GAMEID", "206923")
- target_sid = int(os.environ.get("CQ2_SERVER_ID", "14414738"))
- target_name = os.environ.get("CQ2_SERVER_NAME", "玖扬复古176")
- async with httpx.AsyncClient(timeout=15) as c:
- r = await c.get(f"https://list-box.dhsf.xqhuyu.com/box_serverlist/{gameid}.txt")
- data = r.json()
- print(f"Top-level keys: {list(data.keys())[:5]}")
- print(f"Total groups: {len(data)}")
- print()
- # Find target server
- for gid, g in data.items():
- tree = g.get("tree", [])
- for s in tree:
- sid = s.get("serverid", 0)
- name = s.get("server_name", "")
- if sid == target_sid or target_name in name:
- print(f"MATCH: group={gid} sid={sid} name={name}")
- print(f" group list_name: {g.get('list_name')}")
- print(f" server keys: {list(s.keys())}")
- print(f" full server: {json.dumps(s, ensure_ascii=False, indent=2)[:800]}")
- print()
- # Show one example server structure if no match
- print("=== Example server structure (first server in first group) ===")
- first_gid = next(iter(data.keys()))
- first_group = data[first_gid]
- if first_group.get("tree"):
- example = first_group["tree"][0]
- print(f" keys: {list(example.keys())}")
- print(f" full: {json.dumps(example, ensure_ascii=False, indent=2)[:800]}")
- asyncio.run(main())
|