From c5a342cb5d73888233704c15f83e7f38102aa03f Mon Sep 17 00:00:00 2001 From: voson Date: Thu, 30 Jul 2026 23:10:32 +0800 Subject: [PATCH] Survive OpenDota proPlayers 429 during watchlist pro refresh. Continue with watchlist names when /proPlayers is rate-limited, and soft-fail the pro-matches step so daily can still refresh leaderboards and streamers. Co-authored-by: Cursor --- web/fetch_pro_matches.py | 22 +++++++++++++++------- web/refresh_web.py | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/web/fetch_pro_matches.py b/web/fetch_pro_matches.py index 57d5d9d..2cb4098 100644 --- a/web/fetch_pro_matches.py +++ b/web/fetch_pro_matches.py @@ -648,15 +648,10 @@ def main() -> None: client = OpenDotaClient(consecutive_limit=int(args.streak_429)) - _log("loading pro players ...") - pro_index = fetch_pro_index() - _log(f" {len(pro_index)} registered pros") - - player_ids = parse_pro_filter(args.players, pro_index) + player_ids_raw = (args.players or "").strip() watchlist: list[dict] | None = None player_source = "cli" - - if player_ids: + if player_ids_raw: player_source = "cli" elif not args.all_pros: watchlist = load_watchlist(args.watchlist) @@ -670,6 +665,19 @@ def main() -> None: else: player_source = "proPlayers" + _log("loading pro players ...") + try: + pro_index = fetch_pro_index() + except SystemExit as exc: + # Watchlist runs can proceed without /proPlayers when OpenDota is 429'd. + if args.all_pros and not player_ids_raw: + raise + _log(f" warn: {exc}; continuing with watchlist/cli names only") + pro_index = {} + _log(f" {len(pro_index)} registered pros") + + player_ids = parse_pro_filter(args.players, pro_index) + picked = filter_pros( pro_index, with_team=args.with_team, diff --git a/web/refresh_web.py b/web/refresh_web.py index c028ada..7df9dea 100644 --- a/web/refresh_web.py +++ b/web/refresh_web.py @@ -288,6 +288,7 @@ def run_daily(*, dry_run: bool = False) -> bool: "--refresh-limit", "15", dry_run=dry_run, + soft_fail=True, ) # Soft-fail Douyin enrichment (script itself exits 0; keep previous values on miss). run_script("fetch_streamers.py", dry_run=dry_run, soft_fail=True)