From 9c9017486ca0591f67bf6b0570a03d38b3404da6 Mon Sep 17 00:00:00 2001 From: M0ntyP Date: Wed, 30 Aug 2023 08:21:08 +0930 Subject: [PATCH 1/3] Update: ATP Tennis & WTA Tennis Updated scheduled matches to only show if both players are listed, prevents blanks --- apps/atptennis/atp_tennis.star | 31 +++++++++++++++---------------- apps/wtatennis/wta_tennis.star | 33 ++++++++++++++++----------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/apps/atptennis/atp_tennis.star b/apps/atptennis/atp_tennis.star index 24a56a565..7e58a6ce5 100644 --- a/apps/atptennis/atp_tennis.star +++ b/apps/atptennis/atp_tennis.star @@ -49,6 +49,9 @@ Bug fix - Retired matches were not being captured after changing completed match v1.8 Masters 1000 events will have gold color font for the tournament title/city + +v1.9 +Updated scheduled matches to only show if both players are listed, prevents blanks """ load("encoding/json.star", "json") @@ -232,12 +235,15 @@ def main(config): if diffTournStart.hours < 0 and diffTournEnd.hours > 0: for y in range(0, len(ATP_JSON["events"][x]["groupings"][0]["competitions"]), 1): # if the match is scheduled ("pre") and the start time of the match is scheduled for next 12 hrs, add it to the list of scheduled matches - if ATP_JSON["events"][x]["groupings"][0]["competitions"][y]["status"]["type"]["state"] == "pre": - MatchTime = ATP_JSON["events"][EventIndex]["groupings"][0]["competitions"][y]["date"] - MatchTime = time.parse_time(MatchTime, format = "2006-01-02T15:04Z") - diff = MatchTime - now - if diff.hours < 12: - ScheduledMatchList.insert(0, y) + # But only if both players are listed for the scheduled match, this prevents blank scheduled matches + if ATP_JSON["events"][EventIndex]["groupings"][0]["competitions"][y]["status"]["type"]["state"] == "pre": + if "athlete" in ATP_JSON["events"][EventIndex]["groupings"][0]["competitions"][y]["competitors"][0]: + if "athlete" in ATP_JSON["events"][EventIndex]["groupings"][0]["competitions"][y]["competitors"][1]: + MatchTime = ATP_JSON["events"][EventIndex]["groupings"][0]["competitions"][y]["date"] + MatchTime = time.parse_time(MatchTime, format = "2006-01-02T15:04Z") + diff = MatchTime - now + if diff.hours < 12: + ScheduledMatchList.insert(0, y) # if there are more than 2 matches completed in past 24hrs, then we'll need to show them across multiple screens if len(ScheduledMatchList) > 0: @@ -702,16 +708,9 @@ def getScheduledMatches(SelectedTourneyID, EventIndex, ScheduledMatchList, JSON, # pop the index from the list and go straight to that match x = ScheduledMatchList.pop() - # check that we have players before displaying them or display blank line - if "athlete" in JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][0]: - Player1_Name = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][0]["athlete"]["shortName"] - else: - Player1_Name = "" - if "athlete" in JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][1]: - Player2_Name = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][1]["athlete"]["shortName"] - else: - Player2_Name = "" - + Player1_Name = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][0]["athlete"]["shortName"] + Player2_Name = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][1]["athlete"]["shortName"] + # get date & time of match APIDate = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["date"] ParsedDate = time.parse_time(APIDate, format = "2006-01-02T15:04Z").in_location(timezone) diff --git a/apps/wtatennis/wta_tennis.star b/apps/wtatennis/wta_tennis.star index 94011511d..233256b52 100644 --- a/apps/wtatennis/wta_tennis.star +++ b/apps/wtatennis/wta_tennis.star @@ -48,6 +48,9 @@ Bug fix - Retired matches were not being captured after changing completed match v1.8 Changed purple background color on the title bar, made it darker purple WTA 1000 events will have gold color font for the tournament title/city + +v1.9 +Updated scheduled matches to only show if both players are listed, prevents blanks """ load("encoding/json.star", "json") @@ -237,12 +240,15 @@ def main(config): GroupingsID = 1 for y in range(0, len(WTA_JSON["events"][x]["groupings"][GroupingsID]["competitions"]), 1): # if the match is scheduled ("pre") and the start time of the match is scheduled for next 12 hrs, add it to the list of scheduled matches - if WTA_JSON["events"][x]["groupings"][GroupingsID]["competitions"][y]["status"]["type"]["state"] == "pre": - MatchTime = WTA_JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][y]["date"] - MatchTime = time.parse_time(MatchTime, format = "2006-01-02T15:04Z") - diff = MatchTime - now - if diff.hours < 12: - ScheduledMatchList.insert(0, y) + # But only if both players are listed for the scheduled match, this prevents blank scheduled matches + if WTA_JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][y]["status"]["type"]["state"] == "pre": + if "athlete" in WTA_JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][y]["competitors"][0]: + if "athlete" in WTA_JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][y]["competitors"][1]: + MatchTime = WTA_JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][y]["date"] + MatchTime = time.parse_time(MatchTime, format = "2006-01-02T15:04Z") + diff = MatchTime - now + if diff.hours < 12: + ScheduledMatchList.insert(0, y) # if there are more than 2 matches completed in past 24hrs, then we'll need to show them across multiple screens if len(ScheduledMatchList) > 0: @@ -749,17 +755,10 @@ def getScheduledMatches(SelectedTourneyID, EventIndex, ScheduledMatchList, JSON, if JSON["events"][EventIndex]["groupings"][0]["grouping"]["slug"] == "mens-singles": GroupingsID = 1 - - # check that we have players before displaying them or display blank line - if "athlete" in JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][0]: - Player1_Name = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][0]["athlete"]["shortName"] - else: - Player1_Name = "" - if "athlete" in JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][1]: - Player2_Name = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][1]["athlete"]["shortName"] - else: - Player2_Name = "" - + + Player1_Name = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][0]["athlete"]["shortName"] + Player2_Name = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][1]["athlete"]["shortName"] + # get date & time of match APIDate = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["date"] ParsedDate = time.parse_time(APIDate, format = "2006-01-02T15:04Z").in_location(timezone) From 59dcf70612a658222a4caac134bc60f035c4491f Mon Sep 17 00:00:00 2001 From: M0ntyP Date: Wed, 30 Aug 2023 08:24:19 +0930 Subject: [PATCH 2/3] Formatting --- apps/atptennis/atp_tennis.star | 2 +- apps/wtatennis/wta_tennis.star | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/atptennis/atp_tennis.star b/apps/atptennis/atp_tennis.star index 7e58a6ce5..2c415ced9 100644 --- a/apps/atptennis/atp_tennis.star +++ b/apps/atptennis/atp_tennis.star @@ -710,7 +710,7 @@ def getScheduledMatches(SelectedTourneyID, EventIndex, ScheduledMatchList, JSON, Player1_Name = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][0]["athlete"]["shortName"] Player2_Name = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["competitors"][1]["athlete"]["shortName"] - + # get date & time of match APIDate = JSON["events"][EventIndex]["groupings"][0]["competitions"][x]["date"] ParsedDate = time.parse_time(APIDate, format = "2006-01-02T15:04Z").in_location(timezone) diff --git a/apps/wtatennis/wta_tennis.star b/apps/wtatennis/wta_tennis.star index 233256b52..7addf0d65 100644 --- a/apps/wtatennis/wta_tennis.star +++ b/apps/wtatennis/wta_tennis.star @@ -755,10 +755,10 @@ def getScheduledMatches(SelectedTourneyID, EventIndex, ScheduledMatchList, JSON, if JSON["events"][EventIndex]["groupings"][0]["grouping"]["slug"] == "mens-singles": GroupingsID = 1 - + Player1_Name = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][0]["athlete"]["shortName"] Player2_Name = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["competitors"][1]["athlete"]["shortName"] - + # get date & time of match APIDate = JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][x]["date"] ParsedDate = time.parse_time(APIDate, format = "2006-01-02T15:04Z").in_location(timezone) From c64566ab708dab7d747f352270c2987c36d29865 Mon Sep 17 00:00:00 2001 From: M0ntyP Date: Thu, 31 Aug 2023 17:15:06 +0930 Subject: [PATCH 3/3] Update for walkovers --- apps/atptennis/atp_tennis.star | 3 ++- apps/wtatennis/wta_tennis.star | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/atptennis/atp_tennis.star b/apps/atptennis/atp_tennis.star index 2c415ced9..d7a89c687 100644 --- a/apps/atptennis/atp_tennis.star +++ b/apps/atptennis/atp_tennis.star @@ -52,6 +52,7 @@ Masters 1000 events will have gold color font for the tournament title/city v1.9 Updated scheduled matches to only show if both players are listed, prevents blanks +Updated checking for walkovers """ load("encoding/json.star", "json") @@ -193,7 +194,7 @@ def main(config): MatchState = ATP_JSON["events"][x]["groupings"][0]["competitions"][y]["status"]["type"]["description"] # if the match is completed and the start time of the match was < 24 hrs ago, lets add it to the list of completed matches - if MatchState == "Final" or MatchState == "Retired": + if MatchState == "Final" or MatchState == "Retired" or MatchState == "Walkover": MatchTime = ATP_JSON["events"][EventIndex]["groupings"][0]["competitions"][y]["date"] MatchTime = time.parse_time(MatchTime, format = "2006-01-02T15:04Z") diff = MatchTime - now diff --git a/apps/wtatennis/wta_tennis.star b/apps/wtatennis/wta_tennis.star index 7addf0d65..b3cf3fe43 100644 --- a/apps/wtatennis/wta_tennis.star +++ b/apps/wtatennis/wta_tennis.star @@ -51,6 +51,7 @@ WTA 1000 events will have gold color font for the tournament title/city v1.9 Updated scheduled matches to only show if both players are listed, prevents blanks +Updated walkover checking """ load("encoding/json.star", "json") @@ -196,7 +197,7 @@ def main(config): MatchState = WTA_JSON["events"][x]["groupings"][GroupingsID]["competitions"][y]["status"]["type"]["description"] # if the match is completed and the start time of the match was < 24 hrs ago, lets add it to the list of completed matches - if MatchState == "Final" or MatchState == "Retired": + if MatchState == "Final" or MatchState == "Retired" or MatchState == "Walkover": MatchTime = WTA_JSON["events"][EventIndex]["groupings"][GroupingsID]["competitions"][y]["date"] MatchTime = time.parse_time(MatchTime, format = "2006-01-02T15:04Z") diff = MatchTime - now