wrong timestamp
This commit is contained in:
parent
f613203cbe
commit
9515fa9af9
2 changed files with 57 additions and 3 deletions
17
bin/main.ml
17
bin/main.ml
|
|
@ -7,6 +7,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 357;
|
id = 357;
|
||||||
season = 69619;
|
season = 69619;
|
||||||
name = "CWC";
|
name = "CWC";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = true;
|
filter_foreigners = true;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -14,6 +15,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 384;
|
id = 384;
|
||||||
season = 70083;
|
season = 70083;
|
||||||
name = "LIBERTADORES";
|
name = "LIBERTADORES";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -21,6 +23,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 480;
|
id = 480;
|
||||||
season = 70070;
|
season = 70070;
|
||||||
name = "SUDAMERICANA";
|
name = "SUDAMERICANA";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -28,6 +31,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 373;
|
id = 373;
|
||||||
season = 71944;
|
season = 71944;
|
||||||
name = "COPA DO BRASIL";
|
name = "COPA DO BRASIL";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -35,6 +39,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 1596;
|
id = 1596;
|
||||||
season = 69430;
|
season = 69430;
|
||||||
name = "COPA DO NORDESTE";
|
name = "COPA DO NORDESTE";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -42,6 +47,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 1024;
|
id = 1024;
|
||||||
season = 70664;
|
season = 70664;
|
||||||
name = "COPA ARGENTINA";
|
name = "COPA ARGENTINA";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -49,6 +55,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 325;
|
id = 325;
|
||||||
season = 72034;
|
season = 72034;
|
||||||
name = "BRA1";
|
name = "BRA1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -56,6 +63,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 155;
|
id = 155;
|
||||||
season = 77826;
|
season = 77826;
|
||||||
name = "ARG1";
|
name = "ARG1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -63,6 +71,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 278;
|
id = 278;
|
||||||
season = 71306;
|
season = 71306;
|
||||||
name = "URY1";
|
name = "URY1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -70,6 +79,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 11536;
|
id = 11536;
|
||||||
season = 77825;
|
season = 77825;
|
||||||
name = "COL1";
|
name = "COL1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-5;
|
timezone_offset = Some ~-5;
|
||||||
};
|
};
|
||||||
|
|
@ -77,6 +87,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 1335;
|
id = 1335;
|
||||||
season = 76050;
|
season = 76050;
|
||||||
name = "COPA COLOMBIA";
|
name = "COPA COLOMBIA";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-5;
|
timezone_offset = Some ~-5;
|
||||||
};
|
};
|
||||||
|
|
@ -84,6 +95,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 11653;
|
id = 11653;
|
||||||
season = 71131;
|
season = 71131;
|
||||||
name = "CHL1";
|
name = "CHL1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-4;
|
timezone_offset = Some ~-4;
|
||||||
};
|
};
|
||||||
|
|
@ -91,6 +103,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 390;
|
id = 390;
|
||||||
season = 72603;
|
season = 72603;
|
||||||
name = "BRA2";
|
name = "BRA2";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -98,6 +111,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 1221;
|
id = 1221;
|
||||||
season = 71100;
|
season = 71100;
|
||||||
name = "COPA CHILE";
|
name = "COPA CHILE";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = Some ~-4;
|
timezone_offset = Some ~-4;
|
||||||
};
|
};
|
||||||
|
|
@ -105,6 +119,7 @@ let tournaments : Lib.tournament_scrape_context list =
|
||||||
id = 11541;
|
id = 11541;
|
||||||
season = 69831;
|
season = 69831;
|
||||||
name = "PRY1";
|
name = "PRY1";
|
||||||
|
emoji = "🇧🇷";
|
||||||
filter_foreigners = false;
|
filter_foreigners = false;
|
||||||
timezone_offset = None;
|
timezone_offset = None;
|
||||||
};
|
};
|
||||||
|
|
@ -130,7 +145,7 @@ let pp (day : Unix.tm) matches =
|
||||||
in
|
in
|
||||||
if ppd_matches = "" then ""
|
if ppd_matches = "" then ""
|
||||||
else
|
else
|
||||||
sprintf ">%s %02d/%02d:\n%s" (weekday day.tm_wday) day.tm_mday day.tm_mon
|
sprintf ">%s %02d/%02d:\n%s" (weekday day.tm_wday) day.tm_mday (succ day.tm_mon)
|
||||||
ppd_matches
|
ppd_matches
|
||||||
|
|
||||||
let f () =
|
let f () =
|
||||||
|
|
|
||||||
43
lib/lib.ml
43
lib/lib.ml
|
|
@ -62,6 +62,7 @@ type api_match = {
|
||||||
awayScore : api_score;
|
awayScore : api_score;
|
||||||
status : api_status;
|
status : api_status;
|
||||||
time : api_time;
|
time : api_time;
|
||||||
|
id : int;
|
||||||
startTimestamp : int;
|
startTimestamp : int;
|
||||||
}
|
}
|
||||||
[@@yojson.allow_extra_fields] [@@deriving yojson, show]
|
[@@yojson.allow_extra_fields] [@@deriving yojson, show]
|
||||||
|
|
@ -122,6 +123,24 @@ type api_standing = {
|
||||||
type api_standings_total = { standings : api_standing list }
|
type api_standings_total = { standings : api_standing list }
|
||||||
[@@deriving yojson, show]
|
[@@deriving yojson, show]
|
||||||
|
|
||||||
|
type api_short_match = { winnerCode : int } [@@deriving yojson]
|
||||||
|
|
||||||
|
(* type api_team_events_table = (string * api_short_match list) Hashtbl.t *)
|
||||||
|
(* [@@deriving yojson] *)
|
||||||
|
(**)
|
||||||
|
(* type api_team_events_total = { *)
|
||||||
|
(* tournamentTeamEvents : (string, api_team_events_table) Hashtbl.t *)
|
||||||
|
(* } *)
|
||||||
|
(* [@@deriving yojson] *)
|
||||||
|
|
||||||
|
type match_info = { tournament : string } [@@deriving yojson]
|
||||||
|
|
||||||
|
(* type inner_map = (string, match_info list) Hashtbl.t *)
|
||||||
|
(* [@@deriving yojson] *)
|
||||||
|
(**)
|
||||||
|
(* type outer_map = (string, inner_map) Hashtbl.t *)
|
||||||
|
(* [@@deriving yojson] *)
|
||||||
|
|
||||||
type normal_table_row = {
|
type normal_table_row = {
|
||||||
team : api_team;
|
team : api_team;
|
||||||
position : int;
|
position : int;
|
||||||
|
|
@ -165,13 +184,19 @@ type status =
|
||||||
[@@deriving show]
|
[@@deriving show]
|
||||||
|
|
||||||
(* TODO: round info *)
|
(* TODO: round info *)
|
||||||
type match' = { status : status; home_team : api_team; away_team : api_team }
|
type match' = {
|
||||||
|
status : status;
|
||||||
|
home_team : api_team;
|
||||||
|
away_team : api_team;
|
||||||
|
api_id : int;
|
||||||
|
}
|
||||||
[@@deriving show]
|
[@@deriving show]
|
||||||
|
|
||||||
type tournament_scrape_context = {
|
type tournament_scrape_context = {
|
||||||
id : int;
|
id : int;
|
||||||
season : int;
|
season : int;
|
||||||
name : string;
|
name : string;
|
||||||
|
emoji : string;
|
||||||
filter_foreigners : bool;
|
filter_foreigners : bool;
|
||||||
timezone_offset : int option (* assumes UTC-3 if None *);
|
timezone_offset : int option (* assumes UTC-3 if None *);
|
||||||
}
|
}
|
||||||
|
|
@ -254,7 +279,7 @@ let get url =
|
||||||
let req_headers =
|
let req_headers =
|
||||||
Cohttp.Header.(
|
Cohttp.Header.(
|
||||||
add (init ()) "X-Captcha"
|
add (init ()) "X-Captcha"
|
||||||
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NTI4NjM5MjV9.Zv5y-Ba5Kck1JPV2xTBgcfhX0YGhKq-ShTQEGAKG8Uw")
|
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NTQzMTc2MTJ9.sMoqrrTQMoq1JJRJqn-pbOtPIOlOfh5gjrniyUKX_04")
|
||||||
in
|
in
|
||||||
let* resp, body =
|
let* resp, body =
|
||||||
Cohttp_lwt_unix.Client.get ~headers:req_headers @@ Uri.of_string url
|
Cohttp_lwt_unix.Client.get ~headers:req_headers @@ Uri.of_string url
|
||||||
|
|
@ -325,6 +350,7 @@ let matches_of_api_events (e : api_events) =
|
||||||
m.startTimestamp
|
m.startTimestamp
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
api_id = m.id;
|
||||||
home_team = m.homeTeam;
|
home_team = m.homeTeam;
|
||||||
away_team = m.awayTeam;
|
away_team = m.awayTeam;
|
||||||
status =
|
status =
|
||||||
|
|
@ -521,6 +547,7 @@ let matches_of_api_events (e : api_events) =
|
||||||
| _, "postponed", _ -> Postponed
|
| _, "postponed", _ -> Postponed
|
||||||
| _, "suspended", _ ->
|
| _, "suspended", _ ->
|
||||||
Suspended { start_timestamp = m.startTimestamp }
|
Suspended { start_timestamp = m.startTimestamp }
|
||||||
|
| _, "delayed", _ -> Delayed
|
||||||
| a, b, _ ->
|
| a, b, _ ->
|
||||||
failwith
|
failwith
|
||||||
@@ Printf.sprintf "impossible: %s %s %s" a b
|
@@ Printf.sprintf "impossible: %s %s %s" a b
|
||||||
|
|
@ -558,6 +585,10 @@ let fetch_all_matches ctx =
|
||||||
let fetch_all_tournaments tournaments =
|
let fetch_all_tournaments tournaments =
|
||||||
tournaments |> List.map fetch_all_matches |> Lwt.all
|
tournaments |> List.map fetch_all_matches |> Lwt.all
|
||||||
|
|
||||||
|
let fetch_match_details id =
|
||||||
|
let url = sprintf "https://www.sofascore.com/api/v1/event/%d" id in
|
||||||
|
get url >|= Yojson.Safe.from_string
|
||||||
|
|
||||||
let standings context =
|
let standings context =
|
||||||
let url =
|
let url =
|
||||||
sprintf
|
sprintf
|
||||||
|
|
@ -566,3 +597,11 @@ let standings context =
|
||||||
in
|
in
|
||||||
get url >|= Yojson.Safe.from_string >|= api_standings_total_of_yojson
|
get url >|= Yojson.Safe.from_string >|= api_standings_total_of_yojson
|
||||||
>|= tables_of_api_standings_total
|
>|= tables_of_api_standings_total
|
||||||
|
|
||||||
|
(* let last_five_matches context = *)
|
||||||
|
(* let url = *)
|
||||||
|
(* sprintf "https://www.sofascore.com/api/v1/unique-tournament/%d/season/%d/team-events/total" *)
|
||||||
|
(* context.id context.season *)
|
||||||
|
(* in *)
|
||||||
|
(* (* get url >|= Yojson.Safe.from_string >|= *) *)
|
||||||
|
(* ;; *)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue