Skip to content

Commit

Permalink
Merge pull request #322 from UnravelSports/feat/opta_f7
Browse files Browse the repository at this point in the history
Opta Incomplete / Live F7 missing Result tag fix
  • Loading branch information
koenvo committed May 28, 2024
2 parents c58d5b2 + 615e4e9 commit f6e6af5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions kloppy/infra/serializers/event/opta/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,11 @@ def deserialize(self, inputs: OptaInputs) -> EventDataset:
matchdata_path = objectify.ObjectPath(
"SoccerFeed.SoccerDocument.MatchData"
)
match_result_path = objectify.ObjectPath(
"SoccerFeed.SoccerDocument.MatchData.MatchInfo.Result"

result_elements = f7_root.xpath(
"/SoccerFeed/SoccerDocument/MatchData/MatchInfo/Result"
)

team_elms = list(
matchdata_path.find(f7_root).iterchildren("TeamData")
)
Expand All @@ -726,9 +728,12 @@ def deserialize(self, inputs: OptaInputs) -> EventDataset:
)
score = Score(home=home_score, away=away_score)
teams = [home_team, away_team]
match_result_type = list(match_result_path.find(f7_root))[
0
].attrib["Type"]

if result_elements and "Type" in result_elements[0].attrib:
match_result_type = result_elements[0].attrib["Type"]
else:
match_result_type = None

periods = _create_periods(match_result_type)

if len(home_team.players) == 0 or len(away_team.players) == 0:
Expand Down

0 comments on commit f6e6af5

Please sign in to comment.