diff --git a/espn_api/wbasketball/constant.py b/espn_api/wbasketball/constant.py index b54ee98e..3dab95a1 100644 --- a/espn_api/wbasketball/constant.py +++ b/espn_api/wbasketball/constant.py @@ -1,36 +1,22 @@ POSITION_MAP = { - 0: 'PG', - 1: 'SG', - 2: 'SF', - 3: 'PF', - 4: 'C', - 5: 'G', - 6: 'F', - 7: 'SG/SF', - 8: 'G/F', - 9: 'PF/C', - 10: 'F/C', - 11: 'UT', - 12: 'BE', - 13: 'IR', - 14: '', - 15: 'Rookie', + 0: '', + 1: 'G', + 2: 'F', + 3: 'C', + 4: 'F/C', + 5: 'UTIL', + 6: 'BE', + 7: 'IR', + 8: 'Unknown', + 9: 'Unknown', # reverse - 'PG': 0, - 'SG': 1, - 'SF': 2, - 'PF': 3, - 'C': 4, - 'G': 5, - 'F': 6, - 'SG/SF': 7, - 'G/F': 8, - 'PF/C': 9, - 'F/C': 10, - 'UT': 11, - 'BE': 12, - 'IR': 13, - 'Rookie': 15 + 'G': 1, + 'F': 2, + 'C': 3, + 'F/C': 4, + 'UTIL': 5, + 'BE': 6, + 'IR': 7 } PRO_TEAM_MAP = { diff --git a/espn_api/wbasketball/league.py b/espn_api/wbasketball/league.py index c4893c7c..8b827552 100644 --- a/espn_api/wbasketball/league.py +++ b/espn_api/wbasketball/league.py @@ -19,7 +19,7 @@ def __init__(self, league_id: int, year: int, espn_s2=None, swid=None, fetch_lea super().__init__(league_id=league_id, year=year, sport='wnba', espn_s2=espn_s2, swid=swid, debug=debug) if fetch_league: - self._fetch_league() + self.fetch_league() def fetch_league(self): data = self._fetch_league() diff --git a/espn_api/wbasketball/player.py b/espn_api/wbasketball/player.py index bdc2f9b8..ae88b1c0 100644 --- a/espn_api/wbasketball/player.py +++ b/espn_api/wbasketball/player.py @@ -6,7 +6,7 @@ class Player(object): def __init__(self, data, year): self.name = json_parsing(data, 'fullName') self.playerId = json_parsing(data, 'id') - self.position = POSITION_MAP[json_parsing(data, 'defaultPositionId') - 1] + self.position = POSITION_MAP[json_parsing(data, 'defaultPositionId')] self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId'), '') self.eligibleSlots = [POSITION_MAP[pos] for pos in json_parsing(data, 'eligibleSlots')] self.acquisitionType = json_parsing(data, 'acquisitionType') @@ -20,12 +20,12 @@ def __init__(self, data, year): self.injuryStatus = player.get('injuryStatus', self.injuryStatus) self.injured = player.get('injured', False) - for split in player.get('stats', []): + for split in player.get('stats', []): id = self._stat_id_pretty(split['id']) applied_total = split.get('appliedTotal', 0) applied_avg = round(split.get('appliedAverage', 0), 2) self.stats[id] = dict(applied_total=applied_total, applied_avg=applied_avg) - if split['stats']: + if 'stats' in split: if 'averageStats' in split.keys(): self.stats[id]['avg'] = {STATS_MAP[i]: split['averageStats'][i] for i in split['averageStats'].keys() if STATS_MAP[i] != ''} self.stats[id]['total'] = {STATS_MAP[i]: split['stats'][i] for i in split['stats'].keys() if STATS_MAP[i] != ''}