|
logging.debug("Looping through preferred goals for stat box.") |
|
preferred_boxscore_players = boxscore_preferred["players"] |
|
for id, player in preferred_boxscore_players.items(): |
|
try: |
|
if player["stats"]["skaterStats"]["goals"] == 1: |
|
player_name = player["person"]["fullName"] |
|
player_first_name = player_name.split()[0] |
|
player_first_letter = player_first_name[0] |
|
player_last_name = player_name.split()[1] |
|
player_abbrev_name = f"{player_first_letter}. {player_last_name}" |
|
pref_goals_array.append(player_abbrev_name) |
|
elif player["stats"]["skaterStats"]["goals"] > 1: |
|
player_goals = player["stats"]["skaterStats"]["goals"] |
|
player_name = player["person"]["fullName"] |
|
player_first_name = player_name.split()[0] |
|
player_first_letter = player_first_name[0] |
|
player_last_name = player_name.split()[1] |
|
player_abbrev_name = f"{player_first_letter}. {player_last_name} [{player_goals}]" |
|
pref_goals_array.append(player_abbrev_name) |
|
except KeyError: |
|
logging.debug("Stats for %s not available.", player["person"]["fullName"]) |
|
|
|
logging.debug("Looping through preferred goals for stat box.") |
|
other_boxscore_players = boxscore_other["players"] |
|
for id, player in other_boxscore_players.items(): |
|
try: |
|
if player["stats"]["skaterStats"]["goals"] == 1: |
|
player_name = player["person"]["fullName"] |
|
player_first_name = player_name.split()[0] |
|
player_first_letter = player_first_name[0] |
|
player_last_name = player_name.split()[1] |
|
player_abbrev_name = f"{player_first_letter}. {player_last_name}" |
|
other_goals_array.append(player_abbrev_name) |
|
elif player["stats"]["skaterStats"]["goals"] > 1: |
|
player_goals = player["stats"]["skaterStats"]["goals"] |
|
player_name = player["person"]["fullName"] |
|
player_first_name = player_name.split()[0] |
|
player_first_letter = player_first_name[0] |
|
player_last_name = player_name.split()[1] |
|
player_abbrev_name = f"{player_first_letter}. {player_last_name} [{player_goals}]" |
|
other_goals_array.append(player_abbrev_name) |
|
except KeyError: |
|
logging.debug("Stats for %s not available.", player["person"]["fullName"]) |