Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: ATP Tennis & WTA Tennis #1784

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions apps/atptennis/atp_tennis.star
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
Expand Down
32 changes: 16 additions & 16 deletions apps/wtatennis/wta_tennis.star
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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"]
Expand Down