Skip to content

Commit

Permalink
added params/headers into checkRequestStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Litts committed Jan 3, 2025
1 parent a5ccc56 commit e63cfe0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions espn_api/requests/espn_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ESPNUnknownError(Exception):
pass


def checkRequestStatus(status: int, cookies=None, league_id=None, league_endpoint=None, year=None, extend="") -> tuple:
def checkRequestStatus(status: int, cookies=None, league_id=None, league_endpoint=None, year=None, extend="", params=None, headers=None) -> tuple:
if cookies is None:
cookies = {}
if league_id is None:
Expand All @@ -40,7 +40,7 @@ def checkRequestStatus(status: int, cookies=None, league_id=None, league_endpoin

endpoint = alternate_endpoint + extend
#try alternate endpoint
r = requests.get(endpoint, cookies=cookies)
r = requests.get(endpoint, params=params, headers=headers, cookies=cookies)

if r.status_code == 200:
# Return the updated league endpoint if alternate works & the response
Expand Down Expand Up @@ -82,7 +82,7 @@ def __init__(self, sport: str, year: int, league_id: int, cookies: dict = None,
def league_get(self, params: dict = None, headers: dict = None, extend: str = ''):
endpoint = self.LEAGUE_ENDPOINT + extend
r = requests.get(endpoint, params=params, headers=headers, cookies=self.cookies)
alternate_endpoint, alternate_response = checkRequestStatus(r.status_code, cookies=self.cookies, league_id=self.league_id, league_endpoint=self.LEAGUE_ENDPOINT, year=self.year, extend=extend)
alternate_endpoint, alternate_response = checkRequestStatus(r.status_code, cookies=self.cookies, league_id=self.league_id, league_endpoint=self.LEAGUE_ENDPOINT, year=self.year, extend=extend, params=params, headers=headers)

if alternate_endpoint:
self.LEAGUE_ENDPOINT = alternate_endpoint
Expand Down

0 comments on commit e63cfe0

Please sign in to comment.