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

KeyError: -1 when importing League #21

Closed
kstreepy opened this issue Aug 23, 2019 · 8 comments · Fixed by #23
Closed

KeyError: -1 when importing League #21

kstreepy opened this issue Aug 23, 2019 · 8 comments · Fixed by #23

Comments

@kstreepy
Copy link

I'm in 4 leagues. I received this error for 2 of the 4 leagues with the same lines indicated.

KeyError Traceback (most recent call last)
in
----> 1 league_dynasty_18 = League(dynasty_id, year18, espn_s2, swid)

~\Anaconda3\lib\site-packages\ff_espn_api\league.py in init(self, league_id, year, espn_s2, swid)
52 'SWID': self.swid
53 }
---> 54 self._fetch_league()
55
56 def repr(self):

~\Anaconda3\lib\site-packages\ff_espn_api\league.py in _fetch_league(self)
75 self._fetch_players()
76 self._fetch_teams()
---> 77 self._fetch_draft()
78
79 def _fetch_teams(self):

~\Anaconda3\lib\site-packages\ff_espn_api\league.py in _fetch_draft(self)
192 team = self.get_team_data(pick['teamId'])
193 playerId = pick['playerId']
--> 194 playerName = self.player_map[playerId]
195 round_num = pick['roundId']
196 round_pick = pick['roundPickNumber']

KeyError: -1

@cwendt94
Copy link
Owner

I am guessing because this is a dynasty league that if the player was carried over roundPickNumber does not exists

@cwendt94
Copy link
Owner

It should be a easy fix but would be super helpfully if you could attach the data from the endpoint below for the league that it crashes on.

replace "league_id" with your league number.

http://fantasy.espn.com/apis/v3/games/FFL/seasons/2018/segments/0/leagues/league_id?view=mDraftDetail

This endpoint does not have any sensitive data.

@dtcarls
Copy link
Contributor

dtcarls commented Aug 23, 2019

@cwendt94
Copy link
Owner

@kstreepy I am not able to view your league because it is private. Are you able to copy the data to a file and upload it.

@dtcarls thanks for image and league id. I will try to have a fix out sometime this upcoming week!

@kstreepy
Copy link
Author

@cwendt94 My apologies. JSON attached.
51386.txt

@cwendt94
Copy link
Owner

@kstreepy Perfect, thank you!

@cwendt94
Copy link
Owner

@kstreepy I ran that data with unit tests and it didn't crash or get a key error on mine which is strange.

@dtcarls the newest package should fix the player not found error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants