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: 'linescore' #7

Closed
elijahgatchalian opened this issue May 8, 2019 · 4 comments
Closed

KeyError: 'linescore' #7

elijahgatchalian opened this issue May 8, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@elijahgatchalian
Copy link

I got the following error when trying to get information on a game that was postponed:
line 148, in schedule 'current_inning': game['linescore'].get('currentInning',''), KeyError: 'linescore'

Here's the code I used to generate this error:
game_day = statsapi.schedule(team=136,start_date='05/11/2018')

Another postponed date that throws a different error is 04/08/2018.

@toddrob99 toddrob99 self-assigned this May 8, 2019
@toddrob99 toddrob99 added the bug Something isn't working label May 8, 2019
@toddrob99
Copy link
Owner

Thank you for pointing this out. I should not assume the linescore node is present in all cases, so I am checking in a fix for v0.0.8. I will check the 4/8/18 postponed game to see what's going on there too.

@toddrob99
Copy link
Owner

The game on 4/8/18 is failing because there was no probable pitcher listed for the home team. See #6.

@toddrob99
Copy link
Owner

>>> import statsapi
>>> statsapi.__version__
'0.0.8'
>>> statsapi.schedule(team=136,start_date='05/11/2018')
[{'game_id': 529982, 'game_datetime': '2018-05-11T23:10:00Z', 'game_date': '2018-05-11', 'game_type': 'R', 'status': 'Postponed', 'away_name': 'Seattle Mariners', 'home_name': 'Detroit Tigers', 'away_id': 136, 'home_id': 116, 'doubleheader': 'N', 'game_num': 1, 'home_probable_pitcher': 'Boyd, Matthew', 'away_probable_pitcher': 'Gonzales, Marco', 'home_pitcher_note': '', 'away_pitcher_note': '', 'away_score': '0', 'home_score': '0', 'current_inning': '', 'inning_state': '', 'summary': '2018-05-11 - Seattle Mariners @ Detroit Tigers (Postponed)'}]
>>> statsapi.schedule(team=136,start_date='04/08/2018')
[{'game_id': 529544, 'game_datetime': '2018-04-08T18:10:00Z', 'game_date': '2018-04-08', 'game_type': 'R', 'status': 'Postponed', 'away_name': 'Seattle Mariners', 'home_name': 'Minnesota Twins', 'away_id': 136, 'home_id': 142, 'doubleheader': 'N', 'game_num': 1, 'home_probable_pitcher': '', 'away_probable_pitcher': '', 'home_pitcher_note': '', 'away_pitcher_note': '', 'away_score': '0', 'home_score': '0', 'current_inning': '', 'inning_state': '', 'summary': '2018-04-08 - Seattle Mariners @ Minnesota Twins (Postponed)'}]

@toddrob99 toddrob99 mentioned this issue May 8, 2019
toddrob99 added a commit that referenced this issue May 8, 2019
## v0.0.8
* FIX: Error in schedule() when probable pitcher is missing #6 
* FIX: Error in schedule() when linescore is missing (postponed games) #7
@toddrob99
Copy link
Owner

Please update to v0.0.8 with pip install --upgrade MLB-StatsAPI

@skellet0r skellet0r mentioned this issue Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants