Skip to content

Commit

Permalink
Merge pull request #107 from cwendt94/PlayerSatsBug#105
Browse files Browse the repository at this point in the history
Player Applied Stats key error
  • Loading branch information
cwendt94 authored Sep 3, 2020
2 parents 85a755e + 917dda1 commit 2921198
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions espn_api/football/box_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ def __init__(self, data, pro_schedule, positional_rankings, week):
self.pro_pos_rank = positional_rankings[posId][str(opp_id)] if str(opp_id) in positional_rankings[posId] else 0


player_stats = player['stats']
player_stats = player.get('stats')
for stats in player_stats:
if stats['statSourceId'] == 0 and stats['scoringPeriodId'] == week:
self.points = round(stats['appliedTotal'], 2)
self.points_breakdown = {PLAYER_STATS_MAP.get(int(k), k):v for (k,v) in stats['appliedStats'].items()}
elif stats['statSourceId'] == 1 and stats['scoringPeriodId'] == week:
self.projected_points = round(stats['appliedTotal'], 2)
self.projected_breakdown = {PLAYER_STATS_MAP.get(int(k), k):v for (k,v) in stats['appliedStats'].items()}
stats_breakdown = stats.get('appliedStats') if stats.get('appliedStats') else stats.get('stats', {})
points = round(stats.get('appliedTotal', 0), 2)
if stats.get('statSourceId') == 0 and stats.get('scoringPeriodId') == week:
self.points = points
self.points_breakdown = {PLAYER_STATS_MAP.get(int(k), k):v for (k,v) in stats_breakdown.items()}
elif stats.get('statSourceId') == 1 and stats.get('scoringPeriodId') == week:
self.projected_points = points
self.projected_breakdown = {PLAYER_STATS_MAP.get(int(k), k):v for (k,v) in stats_breakdown.items()}



Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name='espn_api',
packages=find_packages(),
version='0.4.1',
version='0.4.2',
author='Christian Wendt',
description='ESPN API',
install_requires=['requests>=2.0.0,<3.0.0'],
Expand Down

0 comments on commit 2921198

Please sign in to comment.