Skip to content

Commit

Permalink
Merge pull request #235 from probberechts/fix/wyscoutv2-teams
Browse files Browse the repository at this point in the history
Fix Wyscout deserialization of teams and players
  • Loading branch information
koenvo authored Nov 24, 2023
2 parents 62d8315 + 5bdf27e commit 91e6c28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
4 changes: 2 additions & 2 deletions kloppy/infra/serializers/event/wyscout/deserializer_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
def _parse_team(raw_events, wyId: str, ground: Ground) -> Team:
team = Team(
team_id=wyId,
name=raw_events["teams"][wyId]["officialName"],
name=raw_events["teams"][wyId]["team"]["officialName"],
ground=ground,
)
team.players = [
Player(
player_id=str(player["playerId"]),
player_id=str(player["player"]["wyId"]),
team=team,
jersey_no=None,
first_name=player["player"]["firstName"],
Expand Down
42 changes: 5 additions & 37 deletions kloppy/tests/files/wyscout_events_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -46690,6 +46690,7 @@
],
"teams": {
"1612": {
"team": {
"wyId": 1612,
"gsmId": 663,
"name": "Liverpool",
Expand All @@ -46704,8 +46705,10 @@
"type": "club",
"category": "default",
"gender": "male"
}
},
"1631": {
"team": {
"wyId": 1631,
"gsmId": 682,
"name": "Leicester City",
Expand All @@ -46720,12 +46723,12 @@
"type": "club",
"category": "default",
"gender": "male"
}
}
},
"players": {
"1612": [
{
"playerId": 15808,
"player": {
"wyId": 15808,
"gsmId": 103265,
Expand Down Expand Up @@ -46760,7 +46763,6 @@
}
},
{
"playerId": 18550,
"player": {
"wyId": 18550,
"gsmId": 159872,
Expand Down Expand Up @@ -46795,7 +46797,6 @@
}
},
{
"playerId": 3802,
"player": {
"wyId": 3802,
"gsmId": 82507,
Expand Down Expand Up @@ -46830,7 +46831,6 @@
}
},
{
"playerId": 25393,
"player": {
"wyId": 25393,
"gsmId": 55819,
Expand Down Expand Up @@ -46865,7 +46865,6 @@
}
},
{
"playerId": 14870,
"player": {
"wyId": 14870,
"gsmId": 101189,
Expand Down Expand Up @@ -46900,7 +46899,6 @@
}
},
{
"playerId": 116,
"player": {
"wyId": 116,
"gsmId": 8828,
Expand Down Expand Up @@ -46935,7 +46933,6 @@
}
},
{
"playerId": 257899,
"player": {
"wyId": 257899,
"gsmId": 290182,
Expand Down Expand Up @@ -46970,7 +46967,6 @@
}
},
{
"playerId": 7964,
"player": {
"wyId": 7964,
"gsmId": 48010,
Expand Down Expand Up @@ -47005,7 +47001,6 @@
}
},
{
"playerId": 8514,
"player": {
"wyId": 8514,
"gsmId": 13465,
Expand Down Expand Up @@ -47040,7 +47035,6 @@
}
},
{
"playerId": 120353,
"player": {
"wyId": 120353,
"gsmId": 138653,
Expand Down Expand Up @@ -47075,7 +47069,6 @@
}
},
{
"playerId": 4908,
"player": {
"wyId": 4908,
"gsmId": 192742,
Expand Down Expand Up @@ -47110,7 +47103,6 @@
}
},
{
"playerId": 74,
"player": {
"wyId": 74,
"gsmId": 2324,
Expand Down Expand Up @@ -47145,7 +47137,6 @@
}
},
{
"playerId": 286831,
"player": {
"wyId": 286831,
"gsmId": 320283,
Expand Down Expand Up @@ -47180,7 +47171,6 @@
}
},
{
"playerId": 346101,
"player": {
"wyId": 346101,
"gsmId": 376875,
Expand Down Expand Up @@ -47215,7 +47205,6 @@
}
},
{
"playerId": 15175,
"player": {
"wyId": 15175,
"gsmId": 205201,
Expand Down Expand Up @@ -47250,7 +47239,6 @@
}
},
{
"playerId": 8319,
"player": {
"wyId": 8319,
"gsmId": 2899,
Expand Down Expand Up @@ -47285,7 +47273,6 @@
}
},
{
"playerId": 7907,
"player": {
"wyId": 7907,
"gsmId": 5206,
Expand Down Expand Up @@ -47320,7 +47307,6 @@
}
},
{
"playerId": 7868,
"player": {
"wyId": 7868,
"gsmId": 120695,
Expand Down Expand Up @@ -47357,7 +47343,6 @@
],
"1631": [
{
"playerId": 26150,
"player": {
"wyId": 26150,
"gsmId": 156662,
Expand Down Expand Up @@ -47392,7 +47377,6 @@
}
},
{
"playerId": 14763,
"player": {
"wyId": 14763,
"gsmId": 5724,
Expand Down Expand Up @@ -47427,7 +47411,6 @@
}
},
{
"playerId": 8013,
"player": {
"wyId": 8013,
"gsmId": 73931,
Expand Down Expand Up @@ -47462,7 +47445,6 @@
}
},
{
"playerId": 8480,
"player": {
"wyId": 8480,
"gsmId": 2841,
Expand Down Expand Up @@ -47497,7 +47479,6 @@
}
},
{
"playerId": 8653,
"player": {
"wyId": 8653,
"gsmId": 182047,
Expand Down Expand Up @@ -47532,7 +47513,6 @@
}
},
{
"playerId": 149019,
"player": {
"wyId": 149019,
"gsmId": 20278,
Expand Down Expand Up @@ -47567,7 +47547,6 @@
}
},
{
"playerId": 8498,
"player": {
"wyId": 8498,
"gsmId": 20816,
Expand Down Expand Up @@ -47602,7 +47581,6 @@
}
},
{
"playerId": 8488,
"player": {
"wyId": 8488,
"gsmId": 47493,
Expand Down Expand Up @@ -47637,7 +47615,6 @@
}
},
{
"playerId": 265366,
"player": {
"wyId": 265366,
"gsmId": 298168,
Expand Down Expand Up @@ -47672,7 +47649,6 @@
}
},
{
"playerId": 350976,
"player": {
"wyId": 350976,
"gsmId": 383419,
Expand Down Expand Up @@ -47707,7 +47683,6 @@
}
},
{
"playerId": 12829,
"player": {
"wyId": 12829,
"gsmId": 159732,
Expand Down Expand Up @@ -47742,7 +47717,6 @@
}
},
{
"playerId": 14853,
"player": {
"wyId": 14853,
"gsmId": 11180,
Expand Down Expand Up @@ -47777,7 +47751,6 @@
}
},
{
"playerId": 217078,
"player": {
"wyId": 217078,
"gsmId": 250541,
Expand Down Expand Up @@ -47812,7 +47785,6 @@
}
},
{
"playerId": 3928,
"player": {
"wyId": 3928,
"gsmId": 21190,
Expand Down Expand Up @@ -47847,7 +47819,6 @@
}
},
{
"playerId": 8066,
"player": {
"wyId": 8066,
"gsmId": 50408,
Expand Down Expand Up @@ -47882,7 +47853,6 @@
}
},
{
"playerId": 119630,
"player": {
"wyId": 119630,
"gsmId": 89404,
Expand Down Expand Up @@ -47917,7 +47887,6 @@
}
},
{
"playerId": 285508,
"player": {
"wyId": 285508,
"gsmId": 319119,
Expand Down Expand Up @@ -47952,7 +47921,6 @@
}
},
{
"playerId": 283142,
"player": {
"wyId": 283142,
"gsmId": 317144,
Expand Down Expand Up @@ -47988,4 +47956,4 @@
}
]
}
}
}

0 comments on commit 91e6c28

Please sign in to comment.