seemethere / nba_py

Python client for NBA statistics located at stats.nba.com
BSD 3-Clause "New" or "Revised" License
1.06k stars 256 forks source link

Current season is last season #103

Open noelvillaman opened 6 years ago

noelvillaman commented 6 years ago

How do I make the current season to be up-to-date? When I print from constants.CurrentSeason or so, it return last years.

rneu31 commented 6 years ago

What are you trying to do?

You can pass the season along to any function/method yourself.

players = PlayerList(season='2017-18').info().DISPLAY_LAST_COMMA_FIRST
noelvillaman commented 6 years ago

I tried ecxacly that and it does not return anything. I am tryinv to get the actual roster. Melo is still a Knick. I also want to get the results of games.

Noel

On Jan 15, 2018 11:03 AM, "Randy" notifications@github.com wrote:

What are you trying to do?

You can pass the season along to any function/method yourself.

players = PlayerList(season='2017-18').info().DISPLAY_LAST_COMMA_FIRST

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/seemethere/nba_py/issues/103#issuecomment-357724034, or mute the thread https://github.com/notifications/unsubscribe-auth/AE7dmpod2IKFDIPEZKwtQDu8wWI0KWOJks5tK3bKgaJpZM4RP_kt .

rneu31 commented 6 years ago

The code I shared was the code that would work if using Pandas. Can you show me exactly what you tried? I can help.

noelvillaman commented 6 years ago

Hi again,

this is what I am trying to do, and I do not thing I using Pandas.

game1 = game.BoxscoreSummary(20180131, '2017-18')

Traceback (most recent call last): File "", line 1, in File "/home/namalliv/virtualenv/namasite/2.7/lib/python2.7/site-packages/nba_py/game.py", line 25, in init 'EndRange': end_range}) File "/home/namalliv/virtualenv/namasite/2.7/lib/python2.7/site-packages/nba_py/init.py", line 85, in _get_json _get.raise_for_status() File "/home/namalliv/virtualenv/namasite/2.7/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://stats.nba.com/stats/boxscoresummaryv2?StartRange=0&GameID=20180131&EndPeriod=0&RangeType=0&Season=2017-18&StartPeriod=0&SeasonType=Regular+Season&EndRange=0

game1 = game.BoxscoreSummary(20180131) Traceback (most recent call last): File "", line 1, in File "/home/namalliv/virtualenv/namasite/2.7/lib/python2.7/site-packages/nba_py/game.py", line 25, in init 'EndRange': end_range}) File "/home/namalliv/virtualenv/namasite/2.7/lib/python2.7/site-packages/nba_py/init.py", line 85, in _get_json _get.raise_for_status() File "/home/namalliv/virtualenv/namasite/2.7/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://stats.nba.com/stats/boxscoresummaryv2?StartRange=0&GameID=20180131&EndPeriod=0&RangeType=0&Season=2016-17&StartPeriod=0&SeasonType=Regular+Season&EndRange=0

So, I am trying to get the information of this season. I would like to see the summary of lastnight game. How would do it?

Thanks,

Noel.

bttmly commented 6 years ago

Your GameID parameter looks malformed -- they are always 10 digits. NBA provides pretty good error responses -- open this in your browser: http://stats.nba.com/stats/boxscoresummaryv2?StartRange=0&GameID=20180131&EndPeriod=0&RangeType=0&Season=2017-18&StartPeriod=0&SeasonType=Regular+Season&EndRange=0

warriors/jazz game from the other night, on NBA website:

http://stats.nba.com/game/0021700751/

matching API request:

http://stats.nba.com/stats/boxscoresummaryv2?StartRange=0&GameID=0021700751&EndPeriod=0&RangeType=0&Season=2016-17&StartPeriod=0&SeasonType=Regular+Season&EndRange=0

where did you get the id 20180131 from?

noelvillaman commented 6 years ago

That was my mistake, I got it from a date in the url: http://www.nba.com/games/20180201/MEMDET#/video I am getting good things now.

BenikaH commented 6 years ago

If you want the current season to be global, go to constants and change current_season to ‘2017-18’. It’s the first line in the script.