Comments (8)
I think you could check the game_type
to determine if the game was rained out or not.
Also, I do not know if I want to make the requests silently fail. Without showing the error message, it could break parts of programs when they try to use what is returned from the function.
from mlbgame.
How did you get the ID for that game? It is not listed by the MLB on the scoreboard for that game. The MLB also has no stats for that game. I can't really do anything if the data is not provided by MLB.com.
from mlbgame.
It was one of the game IDs your module generated it via mlbgame.day(2016, 4, 4). I know you can't get the data if the data aren't provided. I mention this in case you wanted to build in some error checking before your module tries to pull a URL that doesn't exist. When your module tries to pull one of those pages and gets an error, it stops whatever program is running it dead in its tracks.
from mlbgame.
I will add some sort of try/except for that.
from mlbgame.
Note: also seems to happen with some rainouts, for instance last night's Royals/Sox game. The following code generates the same error.
game = mlbgame.day(2016, 5, 16, home="Royals")[0]
stats = mlbgame.player_stats(game.game_id)
Super useful module otherwise.
from mlbgame.
Alright I'll give that a shot. I get not wanting errors to silently fall, though I thought it might be possible to catch them, return a message and then continue on with a routine. Maybe not. I'm a novice coder.
from mlbgame.
I think it would be more beneficial for the user to try/catch so they at least know that something didn't work right.
Also, thanks for using mlbgame.
from mlbgame.
In case anyone runs into the same trouble I did, I thought I'd post the workaround I'm using. I use the mlbgame.game.scoreboard module to generate a list of game IDs with finals. For instance, for the games of May 16, 2016, I use:
statuslist = []
finalgames = []
for game in list(mlbgame.game.scoreboard(2016, 5, 16).keys()):
game_status = (mlbgame.game.scoreboard(2016, 5, 16)[game]['game_status'])
game_id_status = [game, game_status]
statuslist.append(game_id_status)
for item in statuslist:
if item[1] == 'FINAL':
finalgames.append(item)
This creates a list of MLB Game IDs named finalgames
that only includes IDs from games with finals. That list doesn't always play nice with other modules, but when it doesn't it's easy to use scoreboard to get the data I need with my custom list.
from mlbgame.
Related Issues (20)
- `AtBat`'s attributes `des`, `event`, 'des_es`, and `event_es` are occasionally empty HOT 1
- Changing time zone to Pacific HOT 1
- overview(game_id) causes XMLSyntaxError HOT 2
- long return time waits? HOT 2
- Events run very slow HOT 1
- Pypi version (2.5) out of date HOT 1
- Standings pulls
- Can I get data such as if there are runners on first, second, or third, and how many balls and strikes there are? HOT 1
- game_id HOT 3
- Probable Pitchers HOT 3
- Game ID HOT 1
- Home/Away probables listed for wrong team
- mlbgame.injury() gives AttributeError HOT 4
- get_raw_box_score throws 'Could not find a game with that id.' exception for valid game_id
- Getting game events for game with unplayed bottom of final inning causes IndexError
- ValueError: Could not find a game with that id still occurring -- worked yesterday HOT 1
- 2022 Games not appearing HOT 9
- Initial setup to access MLB GD2 Database: HTTP Forbidden
- Not getting a response while running tests
- Import mlbgame could not be resolved HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlbgame.