Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashing issue when returning to lobby #150

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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