Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WNBA Fix Player Positions #552

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 17 additions & 31 deletions espn_api/wbasketball/constant.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
POSITION_MAP = {
0: 'PG',
1: 'SG',
2: 'SF',
3: 'PF',
4: 'C',
5: 'G',
6: 'F',
7: 'SG/SF',
8: 'G/F',
9: 'PF/C',
10: 'F/C',
11: 'UT',
12: 'BE',
13: 'IR',
14: '',
15: 'Rookie',
0: '',
1: 'G',
2: 'F',
3: 'C',
4: 'F/C',
5: 'UTIL',
6: 'BE',
7: 'IR',
8: 'Unknown',
9: 'Unknown',
# reverse
'PG': 0,
'SG': 1,
'SF': 2,
'PF': 3,
'C': 4,
'G': 5,
'F': 6,
'SG/SF': 7,
'G/F': 8,
'PF/C': 9,
'F/C': 10,
'UT': 11,
'BE': 12,
'IR': 13,
'Rookie': 15
'G': 1,
'F': 2,
'C': 3,
'F/C': 4,
'UTIL': 5,
'BE': 6,
'IR': 7
}

PRO_TEAM_MAP = {
Expand Down
2 changes: 1 addition & 1 deletion espn_api/wbasketball/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, league_id: int, year: int, espn_s2=None, swid=None, fetch_lea
super().__init__(league_id=league_id, year=year, sport='wnba', espn_s2=espn_s2, swid=swid, debug=debug)

if fetch_league:
self._fetch_league()
self.fetch_league()

def fetch_league(self):
data = self._fetch_league()
Expand Down
6 changes: 3 additions & 3 deletions espn_api/wbasketball/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Player(object):
def __init__(self, data, year):
self.name = json_parsing(data, 'fullName')
self.playerId = json_parsing(data, 'id')
self.position = POSITION_MAP[json_parsing(data, 'defaultPositionId') - 1]
self.position = POSITION_MAP[json_parsing(data, 'defaultPositionId')]
self.lineupSlot = POSITION_MAP.get(data.get('lineupSlotId'), '')
self.eligibleSlots = [POSITION_MAP[pos] for pos in json_parsing(data, 'eligibleSlots')]
self.acquisitionType = json_parsing(data, 'acquisitionType')
Expand All @@ -20,12 +20,12 @@ def __init__(self, data, year):
self.injuryStatus = player.get('injuryStatus', self.injuryStatus)
self.injured = player.get('injured', False)

for split in player.get('stats', []):
for split in player.get('stats', []):
id = self._stat_id_pretty(split['id'])
applied_total = split.get('appliedTotal', 0)
applied_avg = round(split.get('appliedAverage', 0), 2)
self.stats[id] = dict(applied_total=applied_total, applied_avg=applied_avg)
if split['stats']:
if 'stats' in split:
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] != ''}
Expand Down
Loading