Skip to content

Commit

Permalink
fix: crashing when returning to menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
zayKenyon committed Jul 24, 2023
2 parents 284d2b8 + 7572e34 commit a92b201
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def get_name_from_puuid(self, puuid):

def get_multiple_names_from_puuid(self, puuids):
response = requests.put(self.Requests.pd_url + "/name-service/v2/players", headers=self.Requests.get_headers(), json=puuids, verify=False)

if 'errorCode' in response.json():
self.log(f'{response.json()["errorCode"]}, new token retrieved')
response = requests.put(self.Requests.pd_url + "/name-service/v2/players", headers=self.Requests.get_headers(refresh=True), json=puuids, verify=False)

name_dict = {player["Subject"]: f"{player['GameName']}#{player['TagLine']}"
for player in response.json()}
return name_dict
Expand All @@ -25,4 +30,4 @@ def get_names_from_puuids(self, players):
return self.get_multiple_names_from_puuid(players_puuid)

def get_players_puuid(self, Players):
return [player["Subject"] for player in Players]
return [player["Subject"] for player in Players]
4 changes: 2 additions & 2 deletions src/requestsV.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ def get_lockfile(self):
return dict(zip(keys, data))


def get_headers(self):
if self.headers == {}:
def get_headers(self, refresh=False):
if self.headers == {} or refresh:
local_headers = {'Authorization': 'Basic ' + base64.b64encode(
('riot:' + self.lockfile['password']).encode()).decode()}
response = requests.get(f"https://127.0.0.1:{self.lockfile['port']}/entitlements/v1/token",
Expand Down

0 comments on commit a92b201

Please sign in to comment.