diff --git a/apps/atptennis/atp_tennis.star b/apps/atptennis/atp_tennis.star index 24a56a565..d7a89c687 100644 --- a/apps/atptennis/atp_tennis.star +++ b/apps/atptennis/atp_tennis.star @@ -49,6 +49,10 @@ 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 +Updated checking for walkovers """ load("encoding/json.star", "json") @@ -190,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 @@ -232,12 +236,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,15 +709,8 @@ 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"] diff --git a/apps/wtatennis/wta_tennis.star b/apps/wtatennis/wta_tennis.star index 94011511d..b3cf3fe43 100644 --- a/apps/wtatennis/wta_tennis.star +++ b/apps/wtatennis/wta_tennis.star @@ -48,6 +48,10 @@ 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 +Updated walkover checking """ load("encoding/json.star", "json") @@ -193,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 @@ -237,12 +241,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: @@ -750,15 +757,8 @@ 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"]