Skip to content

Commit

Permalink
Merge pull request #543 from cwendt94/basbeball_player_stat_split
Browse files Browse the repository at this point in the history
Baseball Player Stats only show Season Stats
  • Loading branch information
cwendt94 committed May 8, 2024
2 parents 782a5a4 + a87e215 commit 80bcefc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion espn_api/baseball/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ def __init__(self, data, year):
# add available stats
player_stats = player.get('stats', [])
for stats in player_stats:
if stats.get('seasonId') != year:
stats_split_type = stats.get('statSplitTypeId')
if stats.get('seasonId') != year or (stats_split_type != 0 and stats_split_type != 5):
continue
stats_breakdown = stats.get('stats') or stats.get('appliedStats', {})
breakdown = {STATS_MAP.get(int(k), k):v for (k,v) in stats_breakdown.items()}
points = round(stats.get('appliedTotal', 0), 2)
scoring_period = stats.get('scoringPeriodId')
stat_source = stats.get('statSourceId')
# TODO update stats to include stat split type (0: Season, 1: Last 7 Days, 2: Last 15 Days, 3: Last 30, 4: ??, 5: ?? Used in Box Scores)
(points_type, breakdown_type) = ('points', 'breakdown') if stat_source == 0 else ('projected_points', 'projected_breakdown')
if self.stats.get(scoring_period):
self.stats[scoring_period][points_type] = points
Expand Down

0 comments on commit 80bcefc

Please sign in to comment.