def print_player_abs(player, delta=None): p = mymlbstats._get_player_search(player) if p is None: return "No matching player found" teamid = int(p['team_id']) return get_player( get_game(find_gamepks(None, teamid=teamid, delta=delta)[0]), int(p['player_id']))
async def savant(self, *query: str): """get a link to a player's baseball savant page""" player = mymlbstats._get_player_search(' '.join(query)) if player is not None: name = player['name_display_first_last'].replace(' ', '-') id = player['player_id'] await self.bot.say( "https://baseballsavant.mlb.com/savant-player/%s-%s" % (name, id))
def get_player_savant_stats(player): p = mymlbstats._get_player_search(player) if p is None: return "No matching player found" url = f"https://baseballsavant.mlb.com/savant-player/{p['player_id']}'" page = utils.get_page(url) page = page[page.rfind("var serverVals = {"):] page = page[page.find('{'):page.rfind("};\n") + 1] return loosejson.parse_loosely_defined_json(page)
def print_player_or_team(query, delta=None): teamid = mymlbstats.get_teamid(query) if teamid is None: p = mymlbstats._get_player_search(query) if p is None: return "Query did not match team or player" teamid = int(p['team_id']) return get_player( get_game(find_gamepks(None, teamid=teamid, delta=delta)[0]), int(p['player_id'])) else: return get_five( get_game(find_gamepks(None, teamid=teamid, delta=delta)[0]))