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

[Wyscout v3] Use publicly available wyscout v3 event data #350

Merged
Merged
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
30 changes: 19 additions & 11 deletions kloppy/infra/serializers/event/wyscout/deserializer_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,24 @@ def deserialize(self, inputs: WyscoutInputs) -> EventDataset:
game_id = raw_events["events"][0].get("matchId")
if game_id:
game_id = str(game_id)
coaches = raw_events["coaches"]
if home_team_id in coaches and "coach" in coaches[home_team_id]:
home_coach = coaches[home_team_id]["coach"].get("shortName")
else:
home_coach = None
if away_team_id in coaches and "coach" in coaches[away_team_id]:
away_coach = coaches[away_team_id]["coach"].get("shortName")
else:
away_coach = None
home_coach = None
away_coach = None
coaches = raw_events.get("coaches")
if coaches:
if (
home_team_id in coaches
and "coach" in coaches[home_team_id]
):
home_coach = coaches[home_team_id]["coach"].get(
"shortName"
)
if (
away_team_id in coaches
and "coach" in coaches[away_team_id]
):
away_coach = coaches[away_team_id]["coach"].get(
"shortName"
)

events = []

Expand Down Expand Up @@ -633,8 +642,7 @@ def deserialize(self, inputs: WyscoutInputs) -> EventDataset:
if next_period_id != period_id:
periods[-1] = replace(
periods[-1],
end_timestamp=periods[-1].start_timestamp
+ timedelta(
end_timestamp=timedelta(
seconds=float(
raw_event["second"] + raw_event["minute"] * 60
)
Expand Down
Loading
Loading