This commit is contained in:
silva guimaraes 2025-07-04 19:15:21 -03:00
parent a287461698
commit 4a66e35f8e
2 changed files with 7 additions and 4 deletions

View file

@ -95,8 +95,8 @@ let tournaments : Lib.tournament_scrape_context list =
timezone_offset = Some ~-4; timezone_offset = Some ~-4;
}; };
{ {
id = 11540; id = 11541;
season = 69799; season = 69831;
name = "PRY1"; name = "PRY1";
filter_foreigners = false; filter_foreigners = false;
timezone_offset = None; timezone_offset = None;

View file

@ -156,6 +156,8 @@ end
let ( let* ) = Lwt.bind let ( let* ) = Lwt.bind
exception Status_Not_found
(* TODO: handle "resolution fai led: name resolution failed" *) (* TODO: handle "resolution fai led: name resolution failed" *)
let get url : string = let get url : string =
let http_get url = let http_get url =
@ -163,7 +165,8 @@ let get url : string =
Stdlib.flush Stdlib.stdout; Stdlib.flush Stdlib.stdout;
let* resp, body = Cohttp_lwt_unix.Client.get (Uri.of_string url) in let* resp, body = Cohttp_lwt_unix.Client.get (Uri.of_string url) in
let code = resp |> Cohttp.Response.status |> Cohttp.Code.code_of_status in let code = resp |> Cohttp.Response.status |> Cohttp.Code.code_of_status in
if Cohttp.Code.is_success code then if code = 404 then raise Status_Not_found
else if Cohttp.Code.is_success code then
let* b = Cohttp_lwt.Body.to_string body in let* b = Cohttp_lwt.Body.to_string body in
Lwt.return (Ok b) Lwt.return (Ok b)
else Lwt.return (Error (Cohttp.Code.reason_phrase_of_code code)) else Lwt.return (Error (Cohttp.Code.reason_phrase_of_code code))
@ -228,7 +231,7 @@ let fetch_matches ctx =
ctx.id ctx.season order ctx.id ctx.season order
|> get |> Yojson.Safe.from_string |> api_events_of_yojson |> get |> Yojson.Safe.from_string |> api_events_of_yojson
|> matches_of_api_events |> matches_of_api_events
with Failure str when str = "Not Found" -> [] (* FIXME *) with Status_Not_found -> []
in in
Tournament.make ctx (List.append (g "last") (g "next")) Tournament.make ctx (List.append (g "last") (g "next"))