panzarino/mlbgame

Calling `box_score` gives you an error if it's the top of an inning for a live game

Closed this issue · 1 comments

When I try to call mlb.box_score(some_game_id) when it is the top of an inning of an ongoing game, I get get the following eror: ValueError: invalid literal for int() with base 10: ''. When it is the bottom of an inning everything is fine. Will look into a solution.

Edit: If a team scores during the top of an inning it begins to work.

Full traceback:
Traceback (most recent call last): File "C:\Users\andre\AppData\Local\Programs\Python\Python35\lib\site-packages\mlbgame\game.py", line 270, in __init__ 'home': int(data[x]['home']), ValueError: invalid literal for int() with base 10: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 73, in <module> main() File "main.py", line 67, in main real_time_game() File "main.py", line 57, in real_time_game innings_list = mlb.box_score(game_id).__dict__["innings"] # Get list of innings. Each inning is a dict e.g. {'inning': 1, 'home': 1, 'away': 0} File "C:\Users\andre\AppData\Local\Programs\Python\Python35\lib\site-packages\mlbgame\__init__.py", line 192, in box_score obj = mlbgame.game.GameBoxScore(data) File "C:\Users\andre\AppData\Local\Programs\Python\Python35\lib\site-packages\mlbgame\game.py", line 279, in __init__ 'away': int(data[x]['away']) ValueError: invalid literal for int() with base 10: ''

@panzarino I made a pull request with changes that should resolve the issue