Skip slow proPlayers retries on watchlist pro-match runs.

Use a single fail-fast /proPlayers probe so rate-limited runners start the
15-pro refresh batch immediately from watchlist names.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
voson
2026-07-30 23:10:54 +08:00
co-authored by Cursor
parent c5a342cb5d
commit ee180f3519
+48 -7
View File
@@ -666,14 +666,55 @@ def main() -> None:
player_source = "proPlayers"
_log("loading pro players ...")
try:
pro_index: dict[int, dict] = {}
if args.all_pros and not player_ids_raw:
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 = {}
else:
# Fail-fast: watchlist runs do not need /proPlayers to refresh matches.
try:
raw = http_json(f"{OPENDOTA}/proPlayers", retries=0)
except (
urllib.error.HTTPError,
urllib.error.URLError,
TimeoutError,
json.JSONDecodeError,
OSError,
) as exc:
_log(f" warn: proPlayers unavailable ({exc}); watchlist names only")
raw = None
if isinstance(raw, list):
for row in raw:
if not isinstance(row, dict):
continue
try:
aid = int(row.get("account_id") or 0)
except (TypeError, ValueError):
continue
if aid <= 0:
continue
name = row.get("name")
if isinstance(name, str):
name = name.strip() or None
else:
name = None
team_tag = row.get("team_tag")
if isinstance(team_tag, str):
team_tag = team_tag.strip() or None
else:
team_tag = None
team_name = row.get("team_name")
if isinstance(team_name, str):
team_name = team_name.strip() or None
else:
team_name = None
pro_index[aid] = {
"account_id": aid,
"name": name,
"team_tag": team_tag,
"team_name": team_name,
"country_code": row.get("country_code"),
"last_match_time": row.get("last_match_time"),
}
_log(f" {len(pro_index)} registered pros")
player_ids = parse_pro_filter(args.players, pro_index)