From dabf89aef95f449805f91a004237e915bf8128b6 Mon Sep 17 00:00:00 2001 From: inoble Date: Fri, 23 Feb 2018 13:38:08 +0000 Subject: [PATCH 1/7] Update player.py I have found 24 endpoints from stats.nba.com that are not currently included in nba_py Here are first 6 new endpoints in 6 new classes that can hopefully be added to the master repo I'm quite new to Python and GitHub so please let me know if I'm doing anything wrong, but hopefully I did enough testing on these classes before committing. --- nba_py/player.py | 198 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) diff --git a/nba_py/player.py b/nba_py/player.py index fa9ca84..bd845f2 100644 --- a/nba_py/player.py +++ b/nba_py/player.py @@ -98,6 +98,204 @@ def headline_stats(self): return _api_scrape(self.json, 1) +class PlayerNextNGames: + """ + Contains information about upcoming games for a player + + Args: + :player_id: ID of the player to look up + :number_of_games: Number of future games to look up + :season: Season given to look up + :season_type: Season type to consider (Regular / Playoffs) + + Attributes: + :json: Contains the full json dump to play around with + """ + _endpoint = 'playernextngames' + + def __init__(self, + player_id, + number_of_games, + season=CURRENT_SEASON, + season_type=SeasonType.Default): + self.json = _get_json(endpoint=self._endpoint, + params={'PlayerID': player_id, + 'NumberOfGames': number_of_games, + 'Season': season, + 'SeasonType': season_type}) + + def info(self): + return _api_scrape(self.json, 0) + + +class PlayerFantasyProfileBarGraph: + """ + Fantasy information that can be presented in bar graphs + + Args: + :player_id: ID of the player to look up + :season: Season given to look up + + Attributes: + :json: Contains the full json dump to play around with + """ + _endpoint = 'playerfantasyprofilebargraph' + + def __init__(self, + player_id, + season=CURRENT_SEASON): + self.json = _get_json(endpoint=self._endpoint, + params={'PlayerID': player_id, + 'Season': season}) + + def info(self): + return _api_scrape(self.json, 0) + + def last_five_games(self): + return _api_scrape(self.json, 1) + + +class PlayerFantasyProfile: + """ + Contains fantasy player information + + Args: + :player_id: ID of the player to look up + :measure_type: Specifies type of measure to use (Base, Advanced, etc.) + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :plus_minus: Whether or not to consider plus minus (Y or N) + :pace_adjust: Whether or not to pace adjust stats (Y or N) + :rank: Whether or not to consider rank (Y or N) + :season: Season given to look up + :season_type: Season type to consider (Regular / Playoffs) + + Attributes: + :json: Contains the full json dump to play around with + """ + _endpoint = 'playerfantasyprofile' + + def __init__(self, + player_id, + measure_type=MeasureType.Default, + per_mode=PerMode.Default, + plus_minus=PlusMinus.Default, + pace_adjust=PaceAdjust.Default, + rank=PaceAdjust.Default, + season=CURRENT_SEASON, + season_type=SeasonType.Default,): + self.json = _get_json(endpoint=self._endpoint, + params={'PlayerID': player_id, + 'MeasureType': measure_type, + 'PerMode': per_mode, + 'PlusMinus': plus_minus, + 'PaceAdjust': pace_adjust, + 'Rank': rank, + 'Season': season, + 'SeasonType': season_type}) + + def overall(self): + return _api_scrape(self.json, 0) + + def location(self): + return _api_scrape(self.json, 1) + + def LastNGames(self): + return _api_scrape(self.json, 2) + + def DaysRestModified(self): + return _api_scrape(self.json, 3) + + def Opponent(self): + return _api_scrape(self.json, 4) + + +class PlayerCareerByCollegeRollup: + """ + Contains division 1 college team totals sorted by previous year's tournament seeding + + Args: + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :league_id: ID for the league to look in (Default is 00) + :season_type: Season type to consider (Regular / Playoffs) + + Attributes: + :json: Contains the full json dump to play around with + """ + _endpoint = 'playercareerbycollegerollup' + + def __init__(self, + per_mode=PerMode.Default, + league_id=League.Default, + season_type=SeasonType.Default): + self.json = _get_json(endpoint=self._endpoint, + params={'PerMode': per_mode, + 'LeagueID': league_id, + 'SeasonType': season_type}) + + def east(self): + return _api_scrape(self.json, 0) + + def south(self): + return _api_scrape(self.json, 1) + + def midwest(self): + return _api_scrape(self.json, 2) + + def west(self): + return _api_scrape(self.json, 3) + + +class PlayerCareerByCollege: + """ + Contains a list of nba players and their nba statistics grouped by their college + + Args: + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :league_id: ID for the league to look in (Default is 00) + :season_type: Season type to consider (Regular / Playoffs) + :college: which college the player attended (Duke, UCLA etc.) + + Attributes: + :json: Contains the full json dump to play around with + """ + _endpoint = 'playercareerbycollege' + + def __init__(self, + per_mode=PerMode.Default, + league_id=League.Default, + season_type=SeasonType.Default, + college=0): + self.json = _get_json(endpoint=self._endpoint, + params={'PerMode': per_mode, + 'LeagueID': league_id, + 'SeasonType': season_type, + 'College': college}) + + def info(self): + return _api_scrape(self.json, 0) + + +class PlayerAwards: + """ + Contains information on all awards given to a player (player_id) + + Args: + :player_id: ID of the player to look up + + Attributes: + :json: Contains the full json dump to play around with + """ + _endpoint = 'playerawards' + + def __init__(self, + player_id): + self.json = _get_json(endpoint=self._endpoint, + params={'PlayerID': player_id}) + + def info(self): + return _api_scrape(self.json, 0) + + class _PlayerDashboard: """ Has all the basic arguments for all of the Player Dashboard type objects From 381a2c9c1f7765866cad65b25e28d88edfaee085 Mon Sep 17 00:00:00 2001 From: inoble Date: Fri, 23 Feb 2018 14:43:50 +0000 Subject: [PATCH 2/7] Update player.py Fixed Travis CI suggestions --- nba_py/player.py | 70 ++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/nba_py/player.py b/nba_py/player.py index bd845f2..1b6213b 100644 --- a/nba_py/player.py +++ b/nba_py/player.py @@ -107,7 +107,7 @@ class PlayerNextNGames: :number_of_games: Number of future games to look up :season: Season given to look up :season_type: Season type to consider (Regular / Playoffs) - + Attributes: :json: Contains the full json dump to play around with """ @@ -116,8 +116,8 @@ class PlayerNextNGames: def __init__(self, player_id, number_of_games, - season=CURRENT_SEASON, - season_type=SeasonType.Default): + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default): self.json = _get_json(endpoint=self._endpoint, params={'PlayerID': player_id, 'NumberOfGames': number_of_games, @@ -135,7 +135,7 @@ class PlayerFantasyProfileBarGraph: Args: :player_id: ID of the player to look up :season: Season given to look up - + Attributes: :json: Contains the full json dump to play around with """ @@ -143,7 +143,7 @@ class PlayerFantasyProfileBarGraph: def __init__(self, player_id, - season=CURRENT_SEASON): + season=constants.CURRENT_SEASON): self.json = _get_json(endpoint=self._endpoint, params={'PlayerID': player_id, 'Season': season}) @@ -168,7 +168,7 @@ class PlayerFantasyProfile: :rank: Whether or not to consider rank (Y or N) :season: Season given to look up :season_type: Season type to consider (Regular / Playoffs) - + Attributes: :json: Contains the full json dump to play around with """ @@ -176,13 +176,13 @@ class PlayerFantasyProfile: def __init__(self, player_id, - measure_type=MeasureType.Default, - per_mode=PerMode.Default, - plus_minus=PlusMinus.Default, - pace_adjust=PaceAdjust.Default, - rank=PaceAdjust.Default, - season=CURRENT_SEASON, - season_type=SeasonType.Default,): + measure_type=constants.MeasureType.Default, + per_mode=constants.PerMode.Default, + plus_minus=constants.PlusMinus.Default, + pace_adjust=constants.PaceAdjust.Default, + rank=constants.PaceAdjust.Default, + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default,): self.json = _get_json(endpoint=self._endpoint, params={'PlayerID': player_id, 'MeasureType': measure_type, @@ -195,38 +195,38 @@ def __init__(self, def overall(self): return _api_scrape(self.json, 0) - + def location(self): return _api_scrape(self.json, 1) - + def LastNGames(self): return _api_scrape(self.json, 2) - + def DaysRestModified(self): return _api_scrape(self.json, 3) - + def Opponent(self): return _api_scrape(self.json, 4) - - + + class PlayerCareerByCollegeRollup: """ - Contains division 1 college team totals sorted by previous year's tournament seeding + Contains div1 college team totals sorted by last year's seeding Args: :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) :league_id: ID for the league to look in (Default is 00) :season_type: Season type to consider (Regular / Playoffs) - + Attributes: :json: Contains the full json dump to play around with """ _endpoint = 'playercareerbycollegerollup' def __init__(self, - per_mode=PerMode.Default, - league_id=League.Default, - season_type=SeasonType.Default): + per_mode=constants.PerMode.Default, + league_id=constants.League.Default, + season_type=constants.SeasonType.Default): self.json = _get_json(endpoint=self._endpoint, params={'PerMode': per_mode, 'LeagueID': league_id, @@ -243,27 +243,27 @@ def midwest(self): def west(self): return _api_scrape(self.json, 3) - - + + class PlayerCareerByCollege: """ - Contains a list of nba players and their nba statistics grouped by their college - + Contains list of nba players and their nba stats grouped by their college + Args: :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) :league_id: ID for the league to look in (Default is 00) :season_type: Season type to consider (Regular / Playoffs) :college: which college the player attended (Duke, UCLA etc.) - + Attributes: :json: Contains the full json dump to play around with """ _endpoint = 'playercareerbycollege' def __init__(self, - per_mode=PerMode.Default, - league_id=League.Default, - season_type=SeasonType.Default, + per_mode=constants.PerMode.Default, + league_id=constants.League.Default, + season_type=constants.SeasonType.Default, college=0): self.json = _get_json(endpoint=self._endpoint, params={'PerMode': per_mode, @@ -273,15 +273,15 @@ def __init__(self, def info(self): return _api_scrape(self.json, 0) - - + + class PlayerAwards: """ Contains information on all awards given to a player (player_id) Args: :player_id: ID of the player to look up - + Attributes: :json: Contains the full json dump to play around with """ From 7d4c1915f9b5e56c93ef97c5497748f34ae46f46 Mon Sep 17 00:00:00 2001 From: inoble Date: Sat, 24 Feb 2018 16:31:43 +0000 Subject: [PATCH 3/7] Update player.py Added some parameters that aren't required but can be provided anyway --- nba_py/player.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nba_py/player.py b/nba_py/player.py index 1b6213b..553c471 100644 --- a/nba_py/player.py +++ b/nba_py/player.py @@ -128,13 +128,15 @@ def info(self): return _api_scrape(self.json, 0) -class PlayerFantasyProfileBarGraph: +class PlayerFantasyBarGraph: """ Fantasy information that can be presented in bar graphs Args: :player_id: ID of the player to look up + :league_id: ID for the league to look in (Default is 00) :season: Season given to look up + :season_type: Season type to consider (Regular / Playoffs) Attributes: :json: Contains the full json dump to play around with @@ -143,10 +145,14 @@ class PlayerFantasyProfileBarGraph: def __init__(self, player_id, - season=constants.CURRENT_SEASON): + league_id=constants.League.Default, + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default): self.json = _get_json(endpoint=self._endpoint, params={'PlayerID': player_id, - 'Season': season}) + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type}) def info(self): return _api_scrape(self.json, 0) @@ -161,6 +167,7 @@ class PlayerFantasyProfile: Args: :player_id: ID of the player to look up + :league_id: ID for the league to look in (Default is 00) :measure_type: Specifies type of measure to use (Base, Advanced, etc.) :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) :plus_minus: Whether or not to consider plus minus (Y or N) @@ -176,6 +183,7 @@ class PlayerFantasyProfile: def __init__(self, player_id, + league_id=constants.League.Default, measure_type=constants.MeasureType.Default, per_mode=constants.PerMode.Default, plus_minus=constants.PlusMinus.Default, @@ -185,6 +193,7 @@ def __init__(self, season_type=constants.SeasonType.Default,): self.json = _get_json(endpoint=self._endpoint, params={'PlayerID': player_id, + 'LeagueID': league_id, 'MeasureType': measure_type, 'PerMode': per_mode, 'PlusMinus': plus_minus, @@ -216,6 +225,7 @@ class PlayerCareerByCollegeRollup: Args: :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) :league_id: ID for the league to look in (Default is 00) + :season: Season given to look up :season_type: Season type to consider (Regular / Playoffs) Attributes: @@ -226,10 +236,12 @@ class PlayerCareerByCollegeRollup: def __init__(self, per_mode=constants.PerMode.Default, league_id=constants.League.Default, + season=constants.CURRENT_SEASON, season_type=constants.SeasonType.Default): self.json = _get_json(endpoint=self._endpoint, params={'PerMode': per_mode, 'LeagueID': league_id, + 'Season': season, 'SeasonType': season_type}) def east(self): @@ -252,6 +264,7 @@ class PlayerCareerByCollege: Args: :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) :league_id: ID for the league to look in (Default is 00) + :season: Season given to look up :season_type: Season type to consider (Regular / Playoffs) :college: which college the player attended (Duke, UCLA etc.) @@ -263,11 +276,13 @@ class PlayerCareerByCollege: def __init__(self, per_mode=constants.PerMode.Default, league_id=constants.League.Default, + season=constants.CURRENT_SEASON, season_type=constants.SeasonType.Default, college=0): self.json = _get_json(endpoint=self._endpoint, params={'PerMode': per_mode, 'LeagueID': league_id, + 'Season': season, 'SeasonType': season_type, 'College': college}) From 1c426d2a060ca64270d2a8c6dce041aa03e3dea2 Mon Sep 17 00:00:00 2001 From: inoble Date: Thu, 1 Mar 2018 12:29:30 +0000 Subject: [PATCH 4/7] Update team.py Team hustle stats! Two new endpoints with their classes: TeamHustleLeaders (endpoint: leaguehustlestatsteamleaders) and TeamHustleStats (endpoint: leaguehustlestatsteam) --- nba_py/team.py | 197 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) diff --git a/nba_py/team.py b/nba_py/team.py index adcf03d..955c4d6 100644 --- a/nba_py/team.py +++ b/nba_py/team.py @@ -559,3 +559,200 @@ def shot_area_on_court(self): def shot_area_off_court(self): return _api_scrape(self.json, 8) + + +class TeamHustleLeaders: + """ + Contains league leading hustle stats by team + + Args: + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :league_id: ID for the league to look in (Default is 00) + :season: Season given to look up + :season_type: Season type to consider (Regular or Playoffs) + :playoff_round: Playoff round + :outcome: Filter out by wins or losses + :location: Filter out by home or away + :month: Specify month to filter by + :season_segment: Filter by pre/post all star break + :date_from: Filter out games before a specific date + :date_to: Filter out games after a specific date + :opponent_team_id: Opponent team ID to look up + :vs_conference: Filter by conference + :vs_division: Filter by division + :team_id: ID of the team to look up + :conference: Filter by conference + :division: Filter by division + :player_experience: Player experience (Rookie + :player_position: Filter by position (Forward + :draft_year: Filter by draft year + :draft_pick: Filter by draft pick (1st+Round, Lottery+Pick, etc.) + :college: Filter by college + :country: Filter by country + :height: Filter by player's height + :weight: Filter by player's weight + """ + + _endpoint = 'leaguehustlestatsteamleaders' + + def __init__(self, + per_mode=constants.PerMode.Default, + league_id=constants.League.Default, + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default, + playoff_round=constants.PlayoffRound.Default, + outcome=constants.Outcome.Default, + location=constants.Location.Default, + month=constants.Month.Default, + season_segment=constants.SeasonSegment.Default, + date_from=constants.DateFrom.Default, + date_to=constants.DateTo.Default, + opponent_team_id=constants.OpponentTeamID.Default, + vs_conference=constants.VsConference.Default, + vs_division=constants.VsDivision.Default, + team_id=constants.TeamID.Default, + conference=constants.Conference.Default, + division=constants.Division.Default, + player_experience=constants.PlayerExperience.Default, + player_position=constants.PlayerPosition.Default, + draft_year=constants.DraftYear.Default, + draft_pick=constants.DraftPick.Default, + college=constants.College.Default, + country=constants.Country.Default, + height=constants.Height.Default, + weight=constants.Weight.Default + ): + + self.json = _get_json(endpoint=self._endpoint, + params={ 'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight + }) + + def contested_shots(self): + return _api_scrape(self.json, 0) + + def charges_drawn(self): + return _api_scrape(self.json, 1) + + def deflections(self): + return _api_scrape(self.json, 2) + + def loose_balls(self): + return _api_scrape(self.json, 3) + + def screen_assists(self): + return _api_scrape(self.json, 4) + + +class TeamHustleStats: + """ + Contains hustle stats by team + + Args: + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :league_id: ID for the league to look in (Default is 00) + :season: Season given to look up + :season_type: Season type to consider (Regular or Playoffs) + :playoff_round: Playoff round + :outcome: Filter out by wins or losses + :location: Filter out by home or away + :month: Specify month to filter by + :season_segment: Filter by pre/post all star break + :date_from: Filter out games before a specific date + :date_to: Filter out games after a specific date + :opponent_team_id: Opponent team ID to look up + :vs_conference: Filter by conference + :vs_division: Filter by division + :team_id: ID of the team to look up + :conference: Filter by conference + :division: Filter by division + :player_experience: Player experience (Rookie + :player_position: Filter by position (Forward + :draft_year: Filter by draft year + :draft_pick: Filter by draft pick (1st+Round, Lottery+Pick, etc.) + :college: Filter by college + :country: Filter by country + :height: Filter by player's height + :weight: Filter by player's weight + """ + + _endpoint = 'leaguehustlestatsteam' + + def __init__(self, + per_mode=constants.PerMode.Default, + league_id=constants.League.Default, + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default, + playoff_round=constants.PlayoffRound.Default, + outcome=constants.Outcome.Default, + location=constants.Location.Default, + month=constants.Month.Default, + season_segment=constants.SeasonSegment.Default, + date_from=constants.DateFrom.Default, + date_to=constants.DateTo.Default, + opponent_team_id=constants.OpponentTeamID.Default, + vs_conference=constants.VsConference.Default, + vs_division=constants.VsDivision.Default, + team_id=constants.TeamID.Default, + conference=constants.Conference.Default, + division=constants.Division.Default, + player_experience=constants.PlayerExperience.Default, + player_position=constants.PlayerPosition.Default, + draft_year=constants.DraftYear.Default, + draft_pick=constants.DraftPick.Default, + college=constants.College.Default, + country=constants.Country.Default, + height=constants.Height.Default, + weight=constants.Weight.Default + ): + + self.json = _get_json(endpoint=self._endpoint, + params={ 'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight + }) From 1da360bc905a404839a307af121813c6238d670d Mon Sep 17 00:00:00 2001 From: inoble Date: Thu, 1 Mar 2018 12:38:12 +0000 Subject: [PATCH 5/7] Update player.py Player hustle stats added! 10 of 24 new endpoints now added (if you include teams.py). In this update: Two new endpoints with their classes: PlayerHustleLeaders (endpoint: leaguehustlestatsplayerleaders) and PlayerHustleStats (endpoint: leaguehustlestatsplayer) --- nba_py/player.py | 200 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/nba_py/player.py b/nba_py/player.py index 553c471..9b9c626 100644 --- a/nba_py/player.py +++ b/nba_py/player.py @@ -311,6 +311,206 @@ def info(self): return _api_scrape(self.json, 0) +class PlayerHustleLeaders: + """ + Contains league leading hustle stats by player + + Args: + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :league_id: ID for the league to look in (Default is 00) + :season: Season given to look up + :season_type: Season type to consider (Regular or Playoffs) + :playoff_round: Playoff round + :outcome: Filter out by wins or losses + :location: Filter out by home or away + :month: Specify month to filter by + :season_segment: Filter by pre/post all star break + :date_from: Filter out games before a specific date + :date_to: Filter out games after a specific date + :opponent_team_id: Opponent team ID to look up + :vs_conference: Filter by conference + :vs_division: Filter by division + :team_id: ID of the team to look up + :conference: Filter by conference + :division: Filter by division + :player_experience: Player experience (Rookie + :player_position: Filter by position (Forward + :draft_year: Filter by draft year + :draft_pick: Filter by draft pick (1st+Round, Lottery+Pick, etc.) + :college: Filter by college + :country: Filter by country + :height: Filter by player's height + :weight: Filter by player's weight + """ + + _endpoint = 'leaguehustlestatsplayerleaders' + + def __init__(self, + per_mode=constants.PerMode.Default, + league_id=constants.League.Default, + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default, + playoff_round=constants.PlayoffRound.Default, + outcome=constants.Outcome.Default, + location=constants.Location.Default, + month=constants.Month.Default, + season_segment=constants.SeasonSegment.Default, + date_from=constants.DateFrom.Default, + date_to=constants.DateTo.Default, + opponent_team_id=constants.OpponentTeamID.Default, + vs_conference=constants.VsConference.Default, + vs_division=constants.VsDivision.Default, + team_id=constants.TeamID.Default, + conference=constants.Conference.Default, + division=constants.Division.Default, + player_experience=constants.PlayerExperience.Default, + player_position=constants.PlayerPosition.Default, + draft_year=constants.DraftYear.Default, + draft_pick=constants.DraftPick.Default, + college=constants.College.Default, + country=constants.Country.Default, + height=constants.Height.Default, + weight=constants.Weight.Default + ): + + self.json = _get_json(endpoint=self._endpoint, + params={ 'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight + }) + + def contested_shots(self): + return _api_scrape(self.json, 0) + + def charges_drawn(self): + return _api_scrape(self.json, 1) + + def deflections(self): + return _api_scrape(self.json, 2) + + def loose_balls(self): + return _api_scrape(self.json, 3) + + def screen_assists(self): + return _api_scrape(self.json, 4) + + +class PlayerHustleStats: + """ + Contains hustle stats by player + + Args: + :per_mode: Mode to measure statistics (Totals, PerGame, Per36, etc.) + :league_id: ID for the league to look in (Default is 00) + :season: Season given to look up + :season_type: Season type to consider (Regular or Playoffs) + :playoff_round: Playoff round + :outcome: Filter out by wins or losses + :location: Filter out by home or away + :month: Specify month to filter by + :season_segment: Filter by pre/post all star break + :date_from: Filter out games before a specific date + :date_to: Filter out games after a specific date + :opponent_team_id: Opponent team ID to look up + :vs_conference: Filter by conference + :vs_division: Filter by division + :team_id: ID of the team to look up + :conference: Filter by conference + :division: Filter by division + :player_experience: Player experience (Rookie + :player_position: Filter by position (Forward + :draft_year: Filter by draft year + :draft_pick: Filter by draft pick (1st+Round, Lottery+Pick, etc.) + :college: Filter by college + :country: Filter by country + :height: Filter by player's height + :weight: Filter by player's weight + """ + + _endpoint = 'leaguehustlestatsplayer' + + def __init__(self, + per_mode=constants.PerMode.Default, + league_id=constants.League.Default, + season=constants.CURRENT_SEASON, + season_type=constants.SeasonType.Default, + playoff_round=constants.PlayoffRound.Default, + outcome=constants.Outcome.Default, + location=constants.Location.Default, + month=constants.Month.Default, + season_segment=constants.SeasonSegment.Default, + date_from=constants.DateFrom.Default, + date_to=constants.DateTo.Default, + opponent_team_id=constants.OpponentTeamID.Default, + vs_conference=constants.VsConference.Default, + vs_division=constants.VsDivision.Default, + team_id=constants.TeamID.Default, + conference=constants.Conference.Default, + division=constants.Division.Default, + player_experience=constants.PlayerExperience.Default, + player_position=constants.PlayerPosition.Default, + draft_year=constants.DraftYear.Default, + draft_pick=constants.DraftPick.Default, + college=constants.College.Default, + country=constants.Country.Default, + height=constants.Height.Default, + weight=constants.Weight.Default + ): + + self.json = _get_json(endpoint=self._endpoint, + params={ 'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight + }) + + def info(self): + return _api_scrape(self.json, 0) + + class _PlayerDashboard: """ Has all the basic arguments for all of the Player Dashboard type objects From 7e8866c9a645d4d530f35c639f2689c21803b3ae Mon Sep 17 00:00:00 2001 From: inoble Date: Thu, 1 Mar 2018 12:45:46 +0000 Subject: [PATCH 6/7] Update team.py fixed Travis CI whitespace issues and added call to _api_scrape inside TeamHustleStats --- nba_py/team.py | 105 +++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/nba_py/team.py b/nba_py/team.py index 955c4d6..ef7aacb 100644 --- a/nba_py/team.py +++ b/nba_py/team.py @@ -624,32 +624,31 @@ def __init__(self, ): self.json = _get_json(endpoint=self._endpoint, - params={ 'PerMode': per_mode, - 'LeagueID': league_id, - 'Season': season, - 'SeasonType': season_type, - 'PORound': playoff_round, - 'Outcome': outcome, - 'Location': location, - 'Month': month, - 'SeasonSegment': season_segment, - 'DateFrom': date_from, - 'DateTo': date_to, - 'OpponentTeamID': opponent_team_id, - 'VsConference': vs_conference, - 'VsDivision': vs_division, - 'TeamID': team_id, - 'Conference': conference, - 'Division': division, - 'PlayerExperience': player_experience, - 'PlayerPosition': player_position, - 'DraftYear': draft_year, - 'DraftPick': draft_pick, - 'College': college, - 'Country': country, - 'Height': height, - 'Weight': weight - }) + params={'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight}) def contested_shots(self): return _api_scrape(self.json, 0) @@ -730,29 +729,31 @@ def __init__(self, ): self.json = _get_json(endpoint=self._endpoint, - params={ 'PerMode': per_mode, - 'LeagueID': league_id, - 'Season': season, - 'SeasonType': season_type, - 'PORound': playoff_round, - 'Outcome': outcome, - 'Location': location, - 'Month': month, - 'SeasonSegment': season_segment, - 'DateFrom': date_from, - 'DateTo': date_to, - 'OpponentTeamID': opponent_team_id, - 'VsConference': vs_conference, - 'VsDivision': vs_division, - 'TeamID': team_id, - 'Conference': conference, - 'Division': division, - 'PlayerExperience': player_experience, - 'PlayerPosition': player_position, - 'DraftYear': draft_year, - 'DraftPick': draft_pick, - 'College': college, - 'Country': country, - 'Height': height, - 'Weight': weight - }) + params={'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight}) + + def info(self): + return _api_scrape(self.json, 0) From bb0da9681719f37c637d04ddd5ea7a4f5e256a4d Mon Sep 17 00:00:00 2001 From: inoble Date: Thu, 1 Mar 2018 12:55:41 +0000 Subject: [PATCH 7/7] Update player.py Travis CI whitespace issues fixed --- nba_py/player.py | 102 +++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/nba_py/player.py b/nba_py/player.py index 9b9c626..bc77bec 100644 --- a/nba_py/player.py +++ b/nba_py/player.py @@ -374,32 +374,31 @@ def __init__(self, ): self.json = _get_json(endpoint=self._endpoint, - params={ 'PerMode': per_mode, - 'LeagueID': league_id, - 'Season': season, - 'SeasonType': season_type, - 'PORound': playoff_round, - 'Outcome': outcome, - 'Location': location, - 'Month': month, - 'SeasonSegment': season_segment, - 'DateFrom': date_from, - 'DateTo': date_to, - 'OpponentTeamID': opponent_team_id, - 'VsConference': vs_conference, - 'VsDivision': vs_division, - 'TeamID': team_id, - 'Conference': conference, - 'Division': division, - 'PlayerExperience': player_experience, - 'PlayerPosition': player_position, - 'DraftYear': draft_year, - 'DraftPick': draft_pick, - 'College': college, - 'Country': country, - 'Height': height, - 'Weight': weight - }) + params={'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight}) def contested_shots(self): return _api_scrape(self.json, 0) @@ -480,32 +479,31 @@ def __init__(self, ): self.json = _get_json(endpoint=self._endpoint, - params={ 'PerMode': per_mode, - 'LeagueID': league_id, - 'Season': season, - 'SeasonType': season_type, - 'PORound': playoff_round, - 'Outcome': outcome, - 'Location': location, - 'Month': month, - 'SeasonSegment': season_segment, - 'DateFrom': date_from, - 'DateTo': date_to, - 'OpponentTeamID': opponent_team_id, - 'VsConference': vs_conference, - 'VsDivision': vs_division, - 'TeamID': team_id, - 'Conference': conference, - 'Division': division, - 'PlayerExperience': player_experience, - 'PlayerPosition': player_position, - 'DraftYear': draft_year, - 'DraftPick': draft_pick, - 'College': college, - 'Country': country, - 'Height': height, - 'Weight': weight - }) + params={'PerMode': per_mode, + 'LeagueID': league_id, + 'Season': season, + 'SeasonType': season_type, + 'PORound': playoff_round, + 'Outcome': outcome, + 'Location': location, + 'Month': month, + 'SeasonSegment': season_segment, + 'DateFrom': date_from, + 'DateTo': date_to, + 'OpponentTeamID': opponent_team_id, + 'VsConference': vs_conference, + 'VsDivision': vs_division, + 'TeamID': team_id, + 'Conference': conference, + 'Division': division, + 'PlayerExperience': player_experience, + 'PlayerPosition': player_position, + 'DraftYear': draft_year, + 'DraftPick': draft_pick, + 'College': college, + 'Country': country, + 'Height': height, + 'Weight': weight}) def info(self): return _api_scrape(self.json, 0)