Giter Club home page Giter Club logo

Comments (8)

panzarino avatar panzarino commented on August 25, 2024 1

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.

panzarino avatar panzarino commented on August 25, 2024

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.

rationalpastime avatar rationalpastime commented on August 25, 2024

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.

panzarino avatar panzarino commented on August 25, 2024

I will add some sort of try/except for that.

from mlbgame.

rationalpastime avatar rationalpastime commented on August 25, 2024

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.

rationalpastime avatar rationalpastime commented on August 25, 2024

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.

panzarino avatar panzarino commented on August 25, 2024

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.

rationalpastime avatar rationalpastime commented on August 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.