From a87e2151c4ad3222c49b87fdbb314ccbae376834 Mon Sep 17 00:00:00 2001 From: Christian Wendt Date: Tue, 7 May 2024 15:54:50 +0000 Subject: [PATCH] Baseball Player Stats only show Season Stats --- espn_api/baseball/player.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/espn_api/baseball/player.py b/espn_api/baseball/player.py index d02aceac..b6755a89 100644 --- a/espn_api/baseball/player.py +++ b/espn_api/baseball/player.py @@ -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