Skip to content

Commit

Permalink
[Hockey] Fix goal updates for unknown teams
Browse files Browse the repository at this point in the history
  • Loading branch information
TrustyJAID committed Feb 2, 2024
1 parent b5765cf commit 036fd36
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions hockey/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,19 @@ def to_goal(self, data: dict, content: Optional[dict] = None) -> Goal:
home_score = self.details.get("homeScore", 0)
away_score = self.details.get("awayScore", 0)
team_id = self.details.get("eventOwnerTeamId")
team_name = TEAM_IDS.get(team_id, _("Unknown Team"))
team = Team.from_json(TEAMS.get(team_name, {}), team_name)
home_team = data.get("homeTeam", {})
away_team = data.get("awayTeam", {})
if team_id == home_team.get("id", -1):
team_name = home_team.get("name", {}).get("default", _("Unknown Team"))
team = Team.from_nhle(home_team)
elif team_id == away_team.get("id", -1):
team_name = away_team.get("name", {}).get("default", _("Unknown Team"))
team = Team.from_nhle(away_team, home=False)

if team_id in TEAM_IDS:
team_name = TEAM_IDS.get(team_id, _("Unknown Team"))
team = Team.from_json(TEAMS.get(team_name, {}), team_name)

period_ord = self.period_descriptor.get("periodType", "REG")
if period_ord == "REG":
period_ord = ORDINALS.get(self.period)
Expand Down

0 comments on commit 036fd36

Please sign in to comment.