From d9354bda6dddb942bd0c2ee44bdd73659b9c7d1e Mon Sep 17 00:00:00 2001 From: Dave McPherson Date: Tue, 30 Nov 2021 23:32:59 -0500 Subject: [PATCH] Quick fix for issue #22 --- harambot/yahoo_api.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/harambot/yahoo_api.py b/harambot/yahoo_api.py index a442910..e5c9f18 100644 --- a/harambot/yahoo_api.py +++ b/harambot/yahoo_api.py @@ -129,14 +129,20 @@ def get_matchups(self): team1_name = team1[0][2]["name"] team1_actual_points = team1[1]['team_points']['total'] team1_projected_points = team1[1]['team_projected_points']['total'] - team1_win_probability = "{:.0%}".format(team1[1]['win_probability']) - team1_details = '***{}*** \n Projected Score: {} \n Actual Score: {} \n Win Probability: {} \n'.format(team1_name, team1_projected_points, team1_actual_points, team1_win_probability) + if 'win_probability' in team1[1]: + team1_win_probability = "{:.0%}".format(team1[1]['win_probability']) + team1_details = '***{}*** \n Projected Score: {} \n Actual Score: {} \n Win Probability: {} \n'.format(team1_name, team1_projected_points, team1_actual_points, team1_win_probability) + else: + team1_details = '***{}*** \n Projected Score: {} \n Actual Score: {} \n'.format(team1_name, team1_projected_points, team1_actual_points) team2 = matchup["1"]["team"] team2_name = team2[0][2]["name"] team2_actual_points = team2[1]['team_points']['total'] team2_projected_points = team2[1]['team_projected_points']['total'] - team2_win_probability = "{:.0%}".format(team2[1]['win_probability']) - team2_details = '\n***{}*** \n Projected Score: {} \n Actual Score: {} \n Win Probability: {}\n'.format(team2_name, team2_projected_points, team2_actual_points, team2_win_probability) + if 'win_probability' in team2[1]: + team2_win_probability = "{:.0%}".format(team2[1]['win_probability']) + team2_details = '\n***{}*** \n Projected Score: {} \n Actual Score: {} \n Win Probability: {}\n'.format(team2_name, team2_projected_points, team2_actual_points, team2_win_probability) + else: + team2_details = '\n***{}*** \n Projected Score: {} \n Actual Score: {} \n'.format(team2_name, team2_projected_points, team2_actual_points) divider = '--------------------------------------' embed.add_field(name="{} vs {}".format(team1_name, team2_name), value=team1_details + team2_details+divider, inline=False) return embed