feat(codechef): implement full CodeChef support (#354)
## Problem CodeChef had no working login, submit, or contest list. The browser selectors were wrong, the contest list was missing present/past contests, and problem/contest URLs were unset. ## Solution Fix login and submit selectors for the Drupal-based site. Paginate `/api/list/contests/past` to collect all 228 Starters, then expand each parent contest into individual division entries (e.g. `START228 (Div. 4)`). Add language IDs, correct `url`/`contest_url`/`standings_url` in metadata, and make `:CP <platform>` open the contest picker directly.
This commit is contained in:
parent
c7f2af16d4
commit
3c11d609f5
26 changed files with 336 additions and 158 deletions
|
|
@ -9,7 +9,7 @@ from typing import Any
|
|||
import httpx
|
||||
|
||||
from .base import BaseScraper, extract_precision
|
||||
from .timeouts import HTTP_TIMEOUT, SUBMIT_POLL_TIMEOUT
|
||||
from .timeouts import HTTP_TIMEOUT
|
||||
from .models import (
|
||||
ContestListResult,
|
||||
ContestSummary,
|
||||
|
|
@ -465,40 +465,8 @@ class CSESScraper(BaseScraper):
|
|||
err = r.text
|
||||
return self._submit_error(f"Submit request failed: {err}")
|
||||
|
||||
info = r.json()
|
||||
submission_id = str(info.get("id", ""))
|
||||
|
||||
for _ in range(60):
|
||||
await asyncio.sleep(2)
|
||||
try:
|
||||
r = await client.get(
|
||||
f"{API_URL}/{SUBMIT_SCOPE}/submissions/{submission_id}",
|
||||
params={"poll": "true"},
|
||||
headers={
|
||||
"X-Auth-Token": token,
|
||||
**HEADERS,
|
||||
},
|
||||
timeout=SUBMIT_POLL_TIMEOUT,
|
||||
)
|
||||
if r.status_code == 200:
|
||||
info = r.json()
|
||||
if not info.get("pending", True):
|
||||
verdict = info.get("result", "unknown")
|
||||
return SubmitResult(
|
||||
success=True,
|
||||
error="",
|
||||
submission_id=submission_id,
|
||||
verdict=verdict,
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return SubmitResult(
|
||||
success=True,
|
||||
error="",
|
||||
submission_id=submission_id,
|
||||
verdict="submitted (poll timed out)",
|
||||
)
|
||||
submission_id = str(r.json().get("id", ""))
|
||||
return SubmitResult(success=True, error="", submission_id=submission_id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue