diff --git a/torchlight_changes_unloze/torchlight3/Torchlight/PlayerManager.py b/torchlight_changes_unloze/torchlight3/Torchlight/PlayerManager.py index 54fab31f..c33b6ccf 100755 --- a/torchlight_changes_unloze/torchlight3/Torchlight/PlayerManager.py +++ b/torchlight_changes_unloze/torchlight3/Torchlight/PlayerManager.py @@ -5,6 +5,8 @@ import logging import requests from .Constants import * +session = requests.Session() + def usteamid_to_steamid(usteamid): for ch in ['[', ']']: if ch in usteamid: @@ -207,8 +209,7 @@ class PlayerManager(): #self.PlayerManager.Logger.info(f"self.UniqueID: {self.UniqueID}") #2024 20th may. giving level based on racetimer rank steam2 = usteamid_to_steamid(self.UniqueID) #converting steam3 to steam2 - #if we did more requests than max 64 around the same time i would consider turning it into a session - r = requests.get(f"https://racebackend.unloze.com/racetimer_endpoints-1.0/api/timers/player/{steam2}") + r = session.get(f"https://racebackend.unloze.com/racetimer_endpoints-1.0/api/timers/player/{steam2}") if "Rank" in r.json(): rank = r.json()["Rank"] #self.PlayerManager.Logger.info(f"rank: {rank}") @@ -229,4 +230,4 @@ class PlayerManager(): def OnDisconnect(self, message): self.Active = False self.Storage = None - self.Torchlight().AudioManager.OnDisconnect(self) \ No newline at end of file + self.Torchlight().AudioManager.OnDisconnect(self)