diff --git a/espn_api/base_league.py b/espn_api/base_league.py index ea456a6f..ea20e10e 100644 --- a/espn_api/base_league.py +++ b/espn_api/base_league.py @@ -51,6 +51,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']: @@ -58,7 +59,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..f7f8919b 100644 --- a/espn_api/football/team.py +++ b/espn_api/football/team.py @@ -36,7 +36,7 @@ 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', []) 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})'