def __init__(self): self._local = lcu.connect() self.token = base64.b64encode(f'riot:{self._local["authorization"]}'.encode()).decode() self.url = "https://" + self._local['url'] self.headers = {'Authorization': f"Basic {self.token}", 'Accept': 'application/json'} self.session = rq.Session() self.session.verify = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'riotgames.pem') self.session.headers = self.headers
def get_connection(self): ''' Parses connection url and port from lockfile ''' connection = lcu.connect(LEAGUE_CLIENT_LOCATION) if connection == 'Ensure the client is running and that you supplied the correct path': self.kwargs = None self.url = None return self.kwargs = { 'verify': False, 'auth': ('riot', connection['authorization']), 'timeout': 30 } self.url = 'https://' + connection['url']
def get_connection(self): ''' Parses connection url and port from lockfile ''' connection = lcu.connect(os.path.expanduser(RIOT_CLIENT_CONFIG)) if connection == 'Ensure the client is running and that you supplied the correct path': raise RiotConnectionException self.kwargs = { 'verify': False, 'auth': ('riot', connection['authorization']), 'timeout': 30 } self.url = 'https://' + connection['url'] try: self.get('/riotclient/region-locale') except requests.RequestException: raise RiotConnectionException
def get_connection(self): ''' Parses connection url and port from lockfile ''' connection = lcu.connect(os.path.expanduser(LEAGUE_CLIENT_PATH)) if connection == 'Ensure the client is running and that you supplied the correct path': raise LeagueConnectionException self.kwargs = { 'verify': False, 'auth': ('riot', connection['authorization']), 'timeout': 30 } self.url = 'https://' + connection['url'] try: self.get('/lol-service-status/v1/lcu-status') except requests.RequestException: raise LeagueConnectionException
def get_connection(self, settings): ''' Parses connection url and port from lockfile ''' try: connection = lcu.connect(config) except IndexError: raise RiotConnectionException if connection == 'Ensure the client is running and that you supplied the correct path': raise RiotConnectionException self.kwargs = { 'verify': False, 'auth': ('riot', connection['authorization']), 'timeout': 30 } self.url = 'https://' + connection['url'] try: self.get('/riotclient/region-locale') except requests.RequestException: raise RiotConnectionException
def get_connection(self, settings): ''' Parses connection url and port from lockfile ''' try: connection = lcu.connect(get_league_client_path()) except IndexError: raise LeagueConnectionException if connection == 'Ensure the client is running and that you supplied the correct path': raise LeagueConnectionException self.kwargs = { 'verify': False, 'auth': ('riot', connection['authorization']), 'timeout': 30 } self.url = 'https://' + connection['url'] try: res = self.get('/lol-service-status/v1/lcu-status') if res.status_code != 200: raise LeagueConnectionException except (requests.RequestException, KeyError, json.decoder.JSONDecodeError): raise LeagueConnectionException
import requests import lcu_connector_python as lcu from requests.auth import HTTPBasicAuth import json connect = lcu.connect("/mnt/c/Riot Games/League of Legends/LeagueClient.exe") print(connect) url = connect['url'] port = connect['port'] url = f"{'https'}://{connect['url']}" print(url) def makeRequest(endpoint, body, method): if method == "POST": r = requests.post( url+ endpoint, auth=('riot', connect['authorization']), data=body, headers={'Accept': 'application/json'} ) return r.json() elif method == "GET": r = requests.get(url + endpoint, auth=('riot', connect['authorization'])) return r.json() GAME_ID = 3705698442 # metadata = makeRequest(f'/lol-replays/v2/metadata/{GAME_ID}/create', # { # "gameEnd": 1626, # "gameType": "MATCHED_GAME",