Skip to content

feat: add get_lineups() and get_formations() - #263

Open
johnhegs wants to merge 1 commit into
Olen:mainfrom
johnhegs:feat/get-lineups
Open

johnhegs wants to merge 1 commit into
Olen:mainfrom
johnhegs:feat/get-lineups

Conversation

@johnhegs

Copy link
Copy Markdown

Summary

Adds get_lineups(uid) and get_formations(), covering Spond's match line-ups — the arrangement of players for a fixture, set in the mobile app.

get_lineups(uid) returns one dict per line-up, as an event may hold more than one. Every player entry carries normalised pitch coordinates x and y in the range 0.0–1.0, with y measured from the opponent's goal to the team's own, so the arrangement can be reconstructed rather than just listed. Where a player is assigned to the slot, the entry also carries a membershipId (joining to get_groups()) and a playerName; a formation slot with nobody assigned omits membershipId and has an empty or absent playerName. formationId is absent when players were positioned freely rather than from a template.

get_formations() returns the formation catalogue (52 entries, team sizes 5–11) used to resolve formationId to a name such as 4-4-2. It is static and shared across all groups, so it is cached on self.formations in line with the other lookups.

Line-ups carry visibility: "HOSTS_AND_ADMINS_ONLY", indicating they are readable only by an event's hosts and admins.

Both are read-only GETs against the existing core/v1 base URL and need only the usual Bearer token. examples/lineups.py prints a text pitch diagram per line-up.

Notes

  • positions[].name in the formation catalogue is a localisation key such as lineup_football_goalkeeper, not a display string. Documented in the docstring.
  • Neither new method checks r.ok, following get_profile, get_groups and get_event_attendance_xlsx. The file is split on this — get_events and get_posts do check. Happy to add the check if you'd prefer.
  • Neither endpoint is documented by Spond, so the same no-guarantees caveat as the rest of the library applies.

Line-ups are created in the Spond mobile app and the web client does not
render them, but the data is served by the same consumer API and needs no
special headers or client identification.

get_lineups(uid) returns one dict per line-up, since an event may hold
several. Only x and y are guaranteed on a player entry: a formation slot
with nobody assigned to it omits membershipId and carries an empty or
absent playerName. Where a player is assigned, membershipId joins to
get_groups(). formationId is absent when players were placed freely rather
than from a template.

get_formations() returns the formation catalogue used to resolve that
formationId to a name such as 4-4-2. It is static and shared across all
groups, so it is cached on self.formations like the other lookups.

examples/lineups.py prints a text pitch diagram per line-up, using the
normalised coordinates to place each player rather than just listing names.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant