示例#1
0
 def get_player_info(self, player_id=None, player_name=None):
     """Get individual stats for a player"""
     if not player_id:
         player_id = _player_id(player_name)
     endpoint = f"people/{player_id}"
     data = _api_request(endpoint)
     if data:
         info = data['people'][0]
         return info
示例#2
0
 def get_career_stats(self, player_id=None, player_name=None):
     """Get career stats for a player"""
     if not player_id:
         player_id = _player_id(player_name)
     stats_endpoint = "stats?stats=yearByYear"
     endpoint = f"people/{player_id}/{stats_endpoint}"
     data = _api_request(endpoint)
     if data:
         seasons = data['stats'][0]['splits']
         return seasons
示例#3
0
 def get_player_stats(self, player_id=None, player_name=None, season=None):
     """Get individual stats for a player"""
     if not player_id:
         player_id = _player_id(player_name)
     player_info = self.get_player_info(player_id)
     player_active = player_info.get('active')
     team = player_info.get('currentTeam')
     if team:
         team = team['id']
     if not season and not player_active:
         raise JockBotNHLException('Season required for inactive players')
     if not season:
         season = _current_season()
     season_endpoint = f"stats?stats=statsSingleSeason&season={season}"
     endpoint = f"people/{player_id}/{season_endpoint}"
     data = _api_request(endpoint)
     if data:
         stats = data['stats'][0]['splits'][0]
         stats['team'] = team
         return stats
示例#4
0
 def test_player_id(self):
     player_id = _helpers._player_id(self.player)
     inactive_player_id = _helpers._player_id(self.inactive_player)
     self.assertEqual(player_id, self.player_id, 'Incorrect Player ID')
     self.assertEqual(inactive_player_id, self.inactive_player_id,
                      'Incorrect Inactive Player ID')
示例#5
0
 def player_id(self):
     if not self._id:
         self._player_id = _player_id(self.player)
     else:
         self._player_id = self._id
     return self._player_id