cwendt94 / espn-api

ESPN Fantasy API! (Football, Basketball)
MIT License
628 stars 199 forks source link

Error when Trying to Pull Box Scores #42

Closed rk92080 closed 5 years ago

rk92080 commented 5 years ago

Tryint to pull box score:

bs=(league.box_scores(1))
print(bs[1].home_team)

And getting the following Error:

File "C:/Users/rkuma343/Documents/Python_Scripts/Fantasy/take12.py", line 85, in players_matchup bs=(league.box_scores(1))

File "C:\Users\rkuma343\Documents\Anaconda\lib\site-packages\ff_espn_api\league.py", line 309, in box_scores box_data = [BoxScore(matchup) for matchup in schedule if str(week) in matchup['home']['pointsByScoringPeriod']]

File "C:\Users\rkuma343\Documents\Anaconda\lib\site-packages\ff_espn_api\league.py", line 309, in box_data = [BoxScore(matchup) for matchup in schedule if str(week) in matchup['home']['pointsByScoringPeriod']]

KeyError: 'pointsByScoringPeriod'

cwendt94 commented 5 years ago

It looks like you are still using the old package. I have updated box_scores in the newest package to pass a filter to the API instead of checking the scoringPeriod myself.

rk92080 commented 5 years ago

Thaknks fot the response. Reinstalled, now im getting another error:

File "C:/Users/rkuma343/Documents/Python_Scripts/Fantasy/take12.py", line 63, in matchup box=league.box_scores(i)

File "C:\Users\rkuma343\Documents\Anaconda\lib\site-packages\ff_espn_api\league.py", line 313, in box_scores box_data = [BoxScore(matchup) for matchup in schedule]

File "C:\Users\rkuma343\Documents\Anaconda\lib\site-packages\ff_espn_api\league.py", line 313, in box_data = [BoxScore(matchup) for matchup in schedule]

File "C:\Users\rkuma343\Documents\Anaconda\lib\site-packages\ff_espn_api\box_score.py", line 7, in init self.home_score = round(data['home']['rosterForCurrentScoringPeriod']['appliedStatTotal'], 2)

KeyError: 'rosterForCurrentScoringPeriod'

cwendt94 commented 5 years ago

What is the value of “i” when you pass it into box_scores? I have found if you go past the current week it will not have the data. I need to add error checking for that so it doesn’t crash.

rk92080 commented 5 years ago

Hey, sorry for the late resposne... looks like i resolved the issue..

cwendt94 commented 5 years ago

No problem! I am actually going to reopen it so I don’t forget to add error checking if the week passed in is greater than current week.