cwendt94 / espn-api

ESPN Fantasy API! (Football, Basketball)
MIT License
544 stars 183 forks source link

Key Error when loading League #523

Closed charliegelman closed 5 months ago

charliegelman commented 5 months ago

Sport

Basketball

Summary

Just calling League(league_id=league_id, year=curr_season, espn_s2=espn_s2, swid=espn_swid) gives an error KeyError: 'location'. I'm guessing this is an issue with ESPN, as now the issue stems from this part of the League class. self.team_name = "%s %s" % (data['location'], data['nickname'])
The team name can be found under data['name'].

Logs/Data

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/espn_api/basketball/league.py", line 20, in __init__
    self.fetch_league()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/espn_api/basketball/league.py", line 24, in fetch_league
    self._fetch_teams(data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/espn_api/basketball/league.py", line 51, in _fetch_teams
    super()._fetch_teams(data, TeamClass=Team, pro_schedule=pro_schedule)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/espn_api/base_league.py", line 64, in _fetch_teams
    self.teams.append(TeamClass(team, roster=roster, member=member, schedule=schedule, year=seasonId, pro_schedule=pro_schedule))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/espn_api/basketball/team.py", line 11, in __init__
    self.team_name = "%s %s" % (data['location'], data['nickname'])
KeyError: 'location'
charliegelman commented 5 months ago

This was an error in espn-api 0.30.0. It's fine in 0.34.0

mlandrum22 commented 5 months ago

I'm on 0.34.1 and received the same KeyError when loading League (for Football)