redid it from requests to session, seems to probably be good enough

This commit is contained in:
jenz 2024-05-21 17:07:48 +02:00
parent 810ee7a86c
commit ffe2120d43

View File

@ -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)
self.Torchlight().AudioManager.OnDisconnect(self)