BurntSushi / nflgame

An API to retrieve and read NFL Game Center JSON data. It can work with real-time data, which can be used for fantasy football.
http://pdoc.burntsushi.net/nflgame
The Unlicense
1.27k stars 413 forks source link

Not showing disqualified or ejected players if more than one #293

Closed mesee298 closed 7 years ago

mesee298 commented 7 years ago

I have the following code:


    games = nflgame.games(2016, week=9, kind='REG')
    plays = nflgame.combine_plays(games)
    all_penalty = plays#.filter(penalty=True)

    for penalty in all_penalty:
        lowered = str(penalty.desc).lower()
        if "disqual" in lowered or "eject" in lowered:
            print('')
            print "Play: ", lowered
            print  "Players in play: ", penalty.players
            print('')
        pGSIS_ID = str(penalty.drive.game.eid)
        pQuarter = str(penalty.time)[:2]
        pPenalty_yds = str(penalty.penalty_yds)

It comes back with the following data:

Play:  (12:55) (no huddle, shotgun) c.kessler pass incomplete short left to a.hawkins. penalty on dal-d.irving, disqualification, offsetting. penalty on cle-c.erving, disqualification, offsetting. both dal #95 irving and cle #74 erving  are ejected
Players in play:  [C.Kessler, A.Hawkins]

Play:  (11:18) (shotgun) n.foles pass incomplete short middle to t.kelce (p.amukamara). penalty on kc-t.kelce, unsportsmanlike conduct, 15 yards, enforced between downs. penalty on kc-t.kelce, disqualification, 15 yards, enforced between downs.
Players in play:  [N.Foles, T.Kelce, P.Amukamara]

As you can see, if only one player was ejected, then it shows correctly, but if more than one player is ejected, it won't show those player as part of the play.

Is there something I'm doing wrong, or a better way of doing this?

mesee298 commented 7 years ago

One other thing. I'm also using NFLDB, so if that would be better, please let me know how I should code that.

BurntSushi commented 7 years ago

The first step to debug this is to look at the raw JSON data. If the player isn't recorded there, then nflgame has no hope of doing it correctly. Please remember that the undocumented JSON that nflgame uses from NFL.com isn't 100% accurate. You'll need to dig and figure out where the discrepancy is.

ochawkeye commented 7 years ago

Kelce recorded a stat on the play you list (he recorded a .receiving_tar).

Neither Irving nor Erving recorded any statistics in the play they were involved in. As far as nflgame is concerned, they were involved in that play just as much as you or I was.

mesee298 commented 7 years ago

Okay. Thanks for the info.