derek-adair / nflgame

A working snapshot of nflgame (for historic purposes). This project is no longer active.
http://nflgame.derekadair.com
The Unlicense
332 stars 100 forks source link

Live playoff games #104

Closed OD1995 closed 4 years ago

OD1995 commented 4 years ago

I am attempting to get live player data for playoff games. The Texans and Chiefs are currently playing, so, assuming I've read the documentation correctly, I believe this should get me a list of live games, from which I can then get player data:

import nflgame

year, week = nflgame.live.current_year_and_week()
games = nflgame.live.current_games(year, week)

year and week are 2019 and 19 respectively. But unfortunately games is an empty list. Am I doing something wrong?

ochawkeye commented 4 years ago

week is actually week 2 of the post season.

>>> import nflgame
>>> games = nflgame.games(year=2019, week=2, kind='POST')
>>> print games
[<nflgame.game.Game object at 0x05038C70>, <nflgame.game.Game object at 0x0463EC10>, <nflgame.game.Game object at 0x0463EE90>, <nflgame.game.Game object at 0x03D40790>]
>>> for game in games:
...     print game
...
MIN (10) at SF (27)
TEN (28) at BAL (12)
HOU (31) at KC (51)
SEA (3) at GB (21)
ochawkeye commented 4 years ago

Edit: Maybe I should stay quiet. Looks like the API has changed from what I use if you see 2019 & 19 for week and year respectively.

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:22:17) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nflgame
>>> year, week = nflgame.live.current_year_and_week()
>>> print year, week
2019 2
>>>
jbarber3388 commented 4 years ago

I think what may be going on is that the feed for getting the date is actually returning the wrong week. Therefore, the data you have is not up to date.

(ENV) C:\Users\jpb71\ENV\Lib\site-packages\nflgame>update_players.py --phase POST Loading games for POST 2019 week 20 Traceback (most recent call last): File "C:\Users\jpb71\ENV\Lib\site-packages\nflgame\update_players.py", line 493, in run() File "C:\Users\jpb71\ENV\Lib\site-packages\nflgame\update_players.py", line 369, in run games = nflgame.games(year, week, kind=phase) File "C:\Users\jpb71\ENV\lib\site-packages\nflgame__init__.py", line 224, in games return list(games_gen(year, week, home, away, kind, started)) TypeError: 'NoneType' object is not iterable`

The way I solved this is by specifying the year/week as parameters to the update calls.

(ENV) C:\Users\jpb71\ENV\Lib\site-packages\nflgame>update_players.py --phase POST --year 2019 --week 1 Loading games for POST 2019 week 1 Downloading team rosters... 33/33 complete. (100.00%) Done! Fetching GSIS identifiers for players not in nflgame... 2/2 complete. (100.00%) Done!

(ENV) C:\Users\jpb71\ENV\Lib\site-packages\nflgame>update_sched.py --phase POST Last updated: 2020-01-16 03:08:36.572015 Updating (2009, POST, 1)... Updating (2009, POST, 2)... Updating (2009, POST, 3)... Updating (2009, POST, 4)... Updating (2010, POST, 1)... Updating (2010, POST, 2)... Updating (2010, POST, 3)... Updating (2010, POST, 4)... Updating (2011, POST, 1)... Updating (2011, POST, 2)... Updating (2011, POST, 3)... Updating (2011, POST, 4)... Updating (2012, POST, 1)... Updating (2012, POST, 2)... Updating (2012, POST, 3)... Updating (2012, POST, 4)... Updating (2013, POST, 1)... Updating (2013, POST, 2)... Updating (2013, POST, 3)... Updating (2013, POST, 4)... Updating (2014, POST, 1)... Updating (2014, POST, 2)... Updating (2014, POST, 3)... Updating (2014, POST, 4)... Updating (2015, POST, 1)... Updating (2015, POST, 2)... Updating (2015, POST, 3)... Updating (2015, POST, 4)... Updating (2016, POST, 1)... Updating (2016, POST, 2)... Updating (2016, POST, 3)... Updating (2016, POST, 4)... Updating (2017, POST, 1)... Updating (2017, POST, 2)... Updating (2017, POST, 3)... Updating (2017, POST, 4)... Updating (2018, POST, 1)... Updating (2018, POST, 2)... Updating (2018, POST, 3)... Updating (2018, POST, 4)... Updating (2019, POST, 1)... Updating (2019, POST, 2)... Updating (2019, POST, 3)... Updating (2019, POST, 4)...

jbarber3388 commented 4 years ago

See #106 for more info.

derek-adair commented 4 years ago

Likely a side-effect of #97 as well. Worth noting that I started recently getting a 403 error in live.py. This was resolved in 68ac391