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

ValueError: Could not find a game with that id. #50

Closed
Hisairnessag3 opened this issue Jan 17, 2018 · 8 comments
Closed

ValueError: Could not find a game with that id. #50

Hisairnessag3 opened this issue Jan 17, 2018 · 8 comments
Labels

Comments

@Hisairnessag3
Copy link

Whats causing this? Just started happening.

code:

import mlbgame
stats = mlbgame.player_stats('2014_06_07_miamlb_chnmlb_1')

for player in stats.home_batting:
print(player.h)

@panzarino
Copy link
Owner

@Hisairnessag3 It appears that the game id is invalid, or there is no way to get data for that game. Either way, it appears that mlb does not have any stats information for that game id. My guess is that the game was cancelled (or something of the like) and therefore does not have any stats data.

@Hisairnessag3
Copy link
Author

Hisairnessag3 commented Jan 17, 2018

uh, I would take a look.

this code breaks with the same error:

def year_games(year):
y = mlbgame.games(year)
games = mlbgame.combine_games(y)
for game in games:
print (game.game_id)

return games

games = year_games(2017)
for game in games:

stats = mlbgame.player_stats(game.game_id)
for player in stats.home_batting:
    print(player.h)

latest version as well. Have tried the individual game ids also obviously.

@panzarino
Copy link
Owner

panzarino commented Jan 17, 2018

@Hisairnessag3 Can you tell me what the game_status is for the games that are breaking?

@Hisairnessag3
Copy link
Author

Hisairnessag3 commented Jan 17, 2018

FINAL

@trevor-viljoen
Copy link
Contributor

It's an issue with GAME_URL. There is an extra / added which creates an invalid URL.

@trevor-viljoen
Copy link
Contributor

It looks like MLB made some changes to how they serve out the files. You can no longer browse directory structure of gd2.mlb.com. If you request the url with the extra /, you get something like this:

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>
gameday/components/game/mlb/year_2014/month_06/day_07//gid_2014_06_07_miamlb_chnmlb_1/boxscore.xml
</Key>

If you remove the extra /, you can retrieve the file. Another option is to use: http://gd-terr-origin.mlb.com/components/game/mlb/ instead of http://gd2.mlb.com/coponents/game/mlb/.

@panzarino
Copy link
Owner

Fixed in #51 and will be included in the next release coming soon.

@panzarino panzarino added bug and removed question labels Jan 17, 2018
@cBrou
Copy link

cBrou commented Jun 6, 2018

Work around for anyone looking to continue pulling the yearly Batting and Pitching files... Add an extra forward slash / at the end of the URI

http://gd2.mlb.com/components/game/mlb/year_2018/batters//

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

No branches or pull requests

4 participants