From 07c17ab10ca878d3233c1fa1e03b8e2250bd5ae1 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 12 May 2021 13:06:54 -0700 Subject: [PATCH 1/2] Football Free Agent Fix Off Season Lookup --- espn_api/base_league.py | 5 +++-- espn_api/football/league.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/espn_api/base_league.py b/espn_api/base_league.py index 3574c0d3..2c91485d 100644 --- a/espn_api/base_league.py +++ b/espn_api/base_league.py @@ -84,8 +84,9 @@ def _get_pro_schedule(self, scoringPeriodId: int = None): pro_team_schedule = {} for team in pro_teams: - if team['id'] != 0 and (str(scoringPeriodId) in team['proGamesByScoringPeriod'].keys() and team['proGamesByScoringPeriod'][str(scoringPeriodId)]): - game_data = team['proGamesByScoringPeriod'][str(scoringPeriodId)][0] + pro_game = team.get('proGamesByScoringPeriod', {}) + if team['id'] != 0 and (str(scoringPeriodId) in pro_game.keys() and pro_game[str(scoringPeriodId)]): + game_data =pro_game[str(scoringPeriodId)][0] pro_team_schedule[team['id']] = (game_data['homeProTeamId'], game_data['date']) if team['id'] == game_data['awayProTeamId'] else (game_data['awayProTeamId'], game_data['date']) return pro_team_schedule diff --git a/espn_api/football/league.py b/espn_api/football/league.py index 628782f7..e4d3dd7d 100644 --- a/espn_api/football/league.py +++ b/espn_api/football/league.py @@ -74,7 +74,7 @@ def _get_positional_ratings(self, week: int): 'scoringPeriodId': week, } data = self.espn_request.league_get(params=params) - ratings = data['positionAgainstOpponent']['positionalRatings'] + ratings = data.get('positionAgainstOpponent', {}).get('positionalRatings', {}) positional_ratings = {} for pos, rating in ratings.items(): From 266fb720588c75a2cccc46438168ecf98dd8ae77 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 12 May 2021 13:17:30 -0700 Subject: [PATCH 2/2] fix spacing --- espn_api/base_league.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/espn_api/base_league.py b/espn_api/base_league.py index 2c91485d..d89c5d81 100644 --- a/espn_api/base_league.py +++ b/espn_api/base_league.py @@ -86,7 +86,7 @@ def _get_pro_schedule(self, scoringPeriodId: int = None): for team in pro_teams: pro_game = team.get('proGamesByScoringPeriod', {}) if team['id'] != 0 and (str(scoringPeriodId) in pro_game.keys() and pro_game[str(scoringPeriodId)]): - game_data =pro_game[str(scoringPeriodId)][0] + game_data = pro_game[str(scoringPeriodId)][0] pro_team_schedule[team['id']] = (game_data['homeProTeamId'], game_data['date']) if team['id'] == game_data['awayProTeamId'] else (game_data['awayProTeamId'], game_data['date']) return pro_team_schedule