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

AssertionError: Unknown QTR value: "Suspended" #95

Closed ochawkeye closed 10 years ago

ochawkeye commented 10 years ago

Not sure exactly what game this is referring to as I don't see anything different on NFL.com, but started receiving this error at around 4:04pm CST today:

P:\Projects\Home Computer\Fantasy Football\2014>python livescoring5.py
2014 2 REG
Traceback (most recent call last):
  File "livescoring5.py", line 435, in <module>
    games = nflgame.games(year, week=week, kind=season_type)
  File "D:\Python27\lib\site-packages\nflgame\__init__.py", line 219, in games
    return list(games_gen(year, week, home, away, kind, started))
  File "D:\Python27\lib\site-packages\nflgame\__init__.py", line 266, in gen
    g = nflgame.game.Game(info['eid'])
  File "D:\Python27\lib\site-packages\nflgame\game.py", line 276, in __init__
    self.time = GameClock(self.data['qtr'], self.data['clock'])
  File "D:\Python27\lib\site-packages\nflgame\game.py", line 170, in __init__
    assert False, 'Unknown QTR value: "%s"' % self.qtr
AssertionError: Unknown QTR value: "Suspended"
ochawkeye commented 10 years ago

This is in regards to STL @ TB.

Due to weather, the game will be temporarily suspended.

Actually, looks like NFL.com doesn't handle it all that well either as it says the game is in OT (last option in their if/else statement I suppose?) image

BurntSushi commented 10 years ago

Blech. I'll get a hack pushed out ASAP. nfldb-update is broken right now because of this.

BurntSushi commented 10 years ago

@ochawkeye If you do pip install --upgrade nfldb then I think you'll get a working nfldb-update. (I bumped the nflgame version dep in nfldb, so it should pull in the latest.)

Otherwise, just pip install --upgrade nflgame manually.

ochawkeye commented 10 years ago

Thanks. Your fix beat the game resuming by about 2 minutes so I didn't get a chance to verify that it did in fact elegantly handle the exception, but I trust you were able to verify?

BurntSushi commented 10 years ago

The "fix" was to remove the assertion and set the quarter to "Pregame" if the given quarter value wasn't recognized.

The right way to fix this is to add another value to the quarter enumeration, but that requires a DB change and I didn't want to do that on a Sunday. :-)