probe_today_open.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. """Live-probe candidate 'today open servers' endpoints with the REAL token from MySQL.
  2. The old pc-api.996hezi.com/box/v1/getTodayOpen 404s. Candidates from the
  3. captures + app.asar JS endpoint map (box/v1 prefix seen on api.996hezi.com).
  4. """
  5. import asyncio
  6. import sys
  7. from pathlib import Path
  8. _HERE = Path(__file__).resolve().parent
  9. sys.path.insert(0, str(_HERE.parent / "src"))
  10. from cq2_sdk.env_loader import load_env
  11. load_env(_HERE.parent / ".env")
  12. from cq2_sdk.login import Box996Login, ManualGeetestSolver
  13. from cq2_sdk.login.box_996 import Box996Error
  14. from cq2_sdk.store import UserStore, connection
  15. # (host, path, note)
  16. CANDIDATES = [
  17. ("https://pc-api.996hezi.com", "/box/v1/getTodayOpen", "old SDK endpoint (404 confirmed)"),
  18. ("https://api.996hezi.com", "/box/v1/getTodayOpen", "same path, api host"),
  19. ("https://api.996hezi.com", "/box/v2/getTodayOpen", "v2"),
  20. ("https://pc-api.996hezi.com", "/v1/homeapi/Gameindex/getTodayOpen", "gameindex style"),
  21. ("https://api.996hezi.com", "/authApi/box/v1/getTodayOpen", "authApi prefix host api"),
  22. ]
  23. async def main() -> int:
  24. with connection() as conn:
  25. u = UserStore(conn).get_by_username("longwu988")
  26. if not u or not u.token:
  27. print("FAIL: no real token in MySQL")
  28. return 1
  29. token = u.token
  30. print(f"token: {token[:30]}...\n")
  31. box = Box996Login(geetest=ManualGeetestSolver(), device_id="00:15:5d:0a:04:00")
  32. box.token = token
  33. for host, path, note in CANDIDATES:
  34. label = f"{host.replace('https://', '')}{path}"
  35. try:
  36. r = await box._request("GET", host, path, params={"gameId": "206923"})
  37. code = r.get("code", "?")
  38. data = r.get("data")
  39. shape = ""
  40. if isinstance(data, list) and data:
  41. first = data[0] if isinstance(data[0], dict) else {}
  42. keys = sorted(first.keys())[:8]
  43. shape = f" list[{len(data)}] keys={keys}"
  44. elif isinstance(data, dict):
  45. shape = f" dict keys={sorted(data.keys())[:8]}"
  46. print(f"[HIT ] {label:<62} code={code}{shape} ({note})")
  47. except Box996Error as e:
  48. print(f"[RESP] {label:<62} code={e.code} msg={e.msg[:40]} ({note})")
  49. except Exception as e:
  50. msg = str(e)
  51. tag = "404" if "404" in msg else ("401" if "401" in msg else type(e).__name__)
  52. print(f"[{tag:<4}] {label:<62} ({note})")
  53. return 0
  54. if __name__ == "__main__":
  55. sys.exit(asyncio.run(main()))