From 4a66e35f8e64cf5aecf92846dcc456c1c3706109 Mon Sep 17 00:00:00 2001 From: silva guimaraes Date: Fri, 4 Jul 2025 19:15:21 -0300 Subject: [PATCH] paraguay --- bin/main.ml | 4 ++-- lib/lib.ml | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/main.ml b/bin/main.ml index 0f28e5a..4870bf1 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -95,8 +95,8 @@ let tournaments : Lib.tournament_scrape_context list = timezone_offset = Some ~-4; }; { - id = 11540; - season = 69799; + id = 11541; + season = 69831; name = "PRY1"; filter_foreigners = false; timezone_offset = None; diff --git a/lib/lib.ml b/lib/lib.ml index 509dcd7..ca81b82 100644 --- a/lib/lib.ml +++ b/lib/lib.ml @@ -156,6 +156,8 @@ end let ( let* ) = Lwt.bind +exception Status_Not_found + (* TODO: handle "resolution fai led: name resolution failed" *) let get url : string = let http_get url = @@ -163,7 +165,8 @@ let get url : string = Stdlib.flush Stdlib.stdout; 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 - 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 Lwt.return (Ok b) else Lwt.return (Error (Cohttp.Code.reason_phrase_of_code code)) @@ -228,7 +231,7 @@ let fetch_matches ctx = ctx.id ctx.season order |> get |> Yojson.Safe.from_string |> api_events_of_yojson |> matches_of_api_events - with Failure str when str = "Not Found" -> [] (* FIXME *) + with Status_Not_found -> [] in Tournament.make ctx (List.append (g "last") (g "next"))