From c359ae8b418f18b10f47a7c3d95b95c79d4d2274 Mon Sep 17 00:00:00 2001 From: Christian Wendt Date: Tue, 5 Dec 2023 17:35:43 +0000 Subject: [PATCH 1/2] feat: Add full owner info to team --- espn_api/base_league.py | 4 +++- espn_api/baseball/team.py | 2 +- espn_api/basketball/team.py | 2 +- espn_api/football/team.py | 3 ++- espn_api/hockey/team.py | 2 +- espn_api/wbasketball/team.py | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/espn_api/base_league.py b/espn_api/base_league.py index 7aea1477..dce8dc38 100644 --- a/espn_api/base_league.py +++ b/espn_api/base_league.py @@ -48,6 +48,7 @@ def _fetch_teams(self, data, TeamClass, pro_schedule = None): teams = data['teams'] schedule = data['schedule'] seasonId = data['seasonId'] + members = data.get('members', []) team_roster = {} for team in data['teams']: @@ -55,7 +56,8 @@ def _fetch_teams(self, data, TeamClass, pro_schedule = None): for team in teams: roster = team_roster[team['id']] - self.teams.append(TeamClass(team, roster=roster, schedule=schedule, year=seasonId, pro_schedule=pro_schedule)) + owners = [member for member in members if member.get('id') == team.get('owners', [''])[0]] + self.teams.append(TeamClass(team, roster=roster, schedule=schedule, year=seasonId, owners=owners, pro_schedule=pro_schedule)) # sort by team ID self.teams = sorted(self.teams, key=lambda x: x.team_id, reverse=False) diff --git a/espn_api/baseball/team.py b/espn_api/baseball/team.py index 1d98233b..45b7929a 100644 --- a/espn_api/baseball/team.py +++ b/espn_api/baseball/team.py @@ -26,7 +26,7 @@ def __init__(self, data, roster, schedule, year, **kwargs): self._fetch_roster(roster) self._fetch_schedule(schedule) - self.owners = data.get('owners', []) + self.owners = kwargs.get('owners', []) def __repr__(self): return f'Team({self.team_name})' diff --git a/espn_api/basketball/team.py b/espn_api/basketball/team.py index 1ab3ae6a..d0cee3b9 100644 --- a/espn_api/basketball/team.py +++ b/espn_api/basketball/team.py @@ -29,7 +29,7 @@ def __init__(self, data, roster, schedule, year, **kwargs): self._fetch_roster(roster, year, kwargs.get('pro_schedule')) self._fetch_schedule(schedule) - self.owners = data.get('owners', []) + self.owners = kwargs.get('owners', []) def __repr__(self): return f'Team({self.team_name})' diff --git a/espn_api/football/team.py b/espn_api/football/team.py index 2f090057..cae28a13 100644 --- a/espn_api/football/team.py +++ b/espn_api/football/team.py @@ -36,7 +36,8 @@ def __init__(self, data, roster, schedule, year, **kwargs): self.mov = [] self._fetch_schedule(schedule) self._fetch_roster(roster, year) - self.owners = data.get('owners', []) + self.owners = kwargs.get('owners', []) + print(self.owners) def __repr__(self): return 'Team(%s)' % (self.team_name, ) diff --git a/espn_api/hockey/team.py b/espn_api/hockey/team.py index 436fb681..1a100326 100644 --- a/espn_api/hockey/team.py +++ b/espn_api/hockey/team.py @@ -33,7 +33,7 @@ def __init__(self, data, roster, schedule, year, **kwargs): self._fetch_roster(roster) self._fetch_schedule(schedule) - self.owners = data.get('owners', []) + self.owners = kwargs.get('owners', []) def __repr__(self): return 'Team(%s)' % (self.team_name,) diff --git a/espn_api/wbasketball/team.py b/espn_api/wbasketball/team.py index e935faa1..d5f3a5ed 100644 --- a/espn_api/wbasketball/team.py +++ b/espn_api/wbasketball/team.py @@ -30,7 +30,7 @@ def __init__(self, data, roster, schedule, year, **kwargs): self._fetch_roster(roster, year) self._fetch_schedule(schedule) - self.owners = data.get('owners', []) + self.owners = kwargs.get('owners', []) def __repr__(self): return f'Team({self.team_name})' From 4edc1cd2ce22d853dc7eda3c5cf768a574e9382a Mon Sep 17 00:00:00 2001 From: Christian Wendt Date: Tue, 5 Dec 2023 18:36:27 +0000 Subject: [PATCH 2/2] remove print --- espn_api/football/team.py | 1 - 1 file changed, 1 deletion(-) diff --git a/espn_api/football/team.py b/espn_api/football/team.py index cae28a13..f7f8919b 100644 --- a/espn_api/football/team.py +++ b/espn_api/football/team.py @@ -37,7 +37,6 @@ def __init__(self, data, roster, schedule, year, **kwargs): self._fetch_schedule(schedule) self._fetch_roster(roster, year) self.owners = kwargs.get('owners', []) - print(self.owners) def __repr__(self): return 'Team(%s)' % (self.team_name, )