Skip to content

Commit

Permalink
Merge pull request #214 from cdchan/baseball-player-eligible-slots
Browse files Browse the repository at this point in the history
Baseball: ignore unknown player positions
  • Loading branch information
cwendt94 authored May 20, 2021
2 parents b935647 + cfdfe29 commit 19613d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions espn_api/baseball/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
15: 'RP',
16: 'BE',
17: 'IL',
18: '18',
19: 'IF', # 1B/2B/SS/3B
22: '22', # Josh Fleming (2020)
# reverse TODO
# 18, 21, 22 have appeared but unknown what position they correspond to
}

PRO_TEAM_MAP = {
Expand Down
2 changes: 1 addition & 1 deletion espn_api/baseball/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, data):
self.playerId = json_parsing(data, 'id')
self.position = POSITION_MAP[json_parsing(data, 'defaultPositionId') - 1]
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId'), '')
self.eligibleSlots = [POSITION_MAP[pos] for pos in json_parsing(data, 'eligibleSlots')]
self.eligibleSlots = [POSITION_MAP.get(pos, pos) for pos in json_parsing(data, 'eligibleSlots')] # if position isn't in position map, just use the position id number
self.acquisitionType = json_parsing(data, 'acquisitionType')
self.proTeam = PRO_TEAM_MAP[json_parsing(data, 'proTeamId')]
self.injuryStatus = json_parsing(data, 'injuryStatus')
Expand Down

0 comments on commit 19613d7

Please sign in to comment.