diff --git a/espn_api/basketball/matchup.py b/espn_api/basketball/matchup.py index 80883d95..6a290a78 100644 --- a/espn_api/basketball/matchup.py +++ b/espn_api/basketball/matchup.py @@ -36,9 +36,9 @@ def _fetch_matchup_info(self, data): self.away_team_live_score = (data['away']['cumulativeScore']['wins'] + data['away']['cumulativeScore']['ties']/2) - self.home_team_cats = { STATS_MAP[i]: {'score': data['home']['cumulativeScore']['scoreByStat'][i]['score'], + self.home_team_cats = { STATS_MAP.get(i, i): {'score': data['home']['cumulativeScore']['scoreByStat'][i]['score'], 'result': data['home']['cumulativeScore']['scoreByStat'][i]['result']} for i in data['home']['cumulativeScore']['scoreByStat'].keys()} - self.away_team_cats = { STATS_MAP[i]: {'score': data['away']['cumulativeScore']['scoreByStat'][i]['score'], + self.away_team_cats = { STATS_MAP.get(i, i): {'score': data['away']['cumulativeScore']['scoreByStat'][i]['score'], 'result': data['away']['cumulativeScore']['scoreByStat'][i]['result']} for i in data['away']['cumulativeScore']['scoreByStat'].keys()} diff --git a/espn_api/basketball/player.py b/espn_api/basketball/player.py index a5194788..3fdc5457 100644 --- a/espn_api/basketball/player.py +++ b/espn_api/basketball/player.py @@ -40,11 +40,11 @@ def __init__(self, data, year, pro_team_schedule = None): self.stats[id] = dict(applied_total=applied_total, applied_avg=applied_avg, team=game.get('team', None), date=game.get('date', None)) if split['stats']: 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] != ''} + self.stats[id]['avg'] = {STATS_MAP.get(i, i): split['averageStats'][i] for i in split['averageStats'].keys() if STATS_MAP.get(i) != ''} + self.stats[id]['total'] = {STATS_MAP.get(i, i): split['stats'][i] for i in split['stats'].keys() if STATS_MAP.get(i) != ''} else: self.stats[id]['avg'] = None - self.stats[id]['total'] = {STATS_MAP[i]: split['stats'][i] for i in split['stats'].keys() if STATS_MAP[i] != ''} + self.stats[id]['total'] = {STATS_MAP.get(i, i): split['stats'][i] for i in split['stats'].keys() if STATS_MAP.get(i) != ''} self.total_points = self.stats.get(f'{year}_total', {}).get('applied_total', 0) self.avg_points = self.stats.get(f'{year}_total', {}).get('applied_avg', 0) self.projected_total_points= self.stats.get(f'{year}_projected', {}).get('applied_total', 0) diff --git a/espn_api/basketball/team.py b/espn_api/basketball/team.py index 3413c71e..313165f0 100644 --- a/espn_api/basketball/team.py +++ b/espn_api/basketball/team.py @@ -23,7 +23,7 @@ def __init__(self, data, member, roster, schedule, year, **kwargs): self.schedule = [] if 'valuesByStat' in data: - self.stats = {STATS_MAP[i]: j for i, j in data['valuesByStat'].items()} + self.stats = {STATS_MAP.get(i, i): j for i, j in data['valuesByStat'].items()} if member: self.owner = f"{member['firstName']} {member['lastName']}" if 'logo' in data: