def __init__(self, serf, config): super().__init__(serf, config) self._lolwatcher: Optional[riotwatcher.RiotWatcher] = None self._tftwatcher: Optional[riotwatcher.RiotWatcher] = None if self.enabled(): self._lolwatcher = riotwatcher.LolWatcher(api_key=self.token()) self._tftwatcher = riotwatcher.TftWatcher(api_key=self.token())
def lol_context(mock_get: mock.MagicMock, request) -> MockContext: import riotwatcher api_key = "abcdefg" yield MockContext( api_key, mock_get, riotwatcher.LolWatcher(api_key, kernel_url=request.param), request.param, )
def __init__(self, username: str, api_key: str, server: str, region: str): """ ### Stats - player_name - Name of player that we want to get stats of. - server - Server which player plays(e.g. eune) - api-key - region - Americas / Europe / Asia / Sea """ self.username = username self.server = server.lower() self.api_key = api_key self.region = region.lower() self.watcher = rw.LolWatcher(self.api_key)
def updateData(): lolWatcher = riotwatcher.LolWatcher(os.environ.get("API_KEY")) region = os.environ.get("REGION") playernames = os.environ.get("PLAYERS").split(",") startingRanks = os.environ.get("STARTING_RANKS").split(",") ignoredPlayers = os.environ.get("IGNORED_PLAYERS").split(",") for str, str2 in zip(playernames, startingRanks): summonerData = lolWatcher.summoner.by_name(region, str) allLeagueData = lolWatcher.league.by_summoner(region, summonerData['id']) startingRankSplit = list(filter(None, str2.split(" "))) if (str in ignoredPlayers): #skip players in ignored player list continue for element in allLeagueData: if (element['queueType'] == "RANKED_SOLO_5x5"): leagueData = element winrate = float(leagueData['wins']) / (leagueData['wins'] + float(leagueData['losses'])) startingLP = rankToLP(startingRankSplit[0], startingRankSplit[1], startingRankSplit[2]) currentLP = rankToLP(leagueData['tier'], leagueData['rank'], leagueData['leaguePoints']) LeagueData.objects.create(name=summonerData['name'], tier=leagueData['tier'], rank=leagueData['rank'], points=leagueData['leaguePoints'], wins=leagueData['wins'], losses=leagueData['losses'], winrate=winrate, progress=currentLP-startingLP)
import os import riotwatcher as rw import pandas as pd from dotenv import load_dotenv import requests import lcu_driver as lcu # Load .env load_dotenv(verbose=True) # Find/Create global variables api_key = os.getenv('API_KEY') watcher = rw.LolWatcher(api_key) default_region = 'na1' connector = lcu.Connector() """ """ # @connector.ready # async def connect(connection): # print('LCU API ready.') # @connector.ready # async def connect(connection): # summoner = await connection.request( # 'get', '/lol-summoner/v1/current-summoner'
import logging import os import json from datetime import datetime from concurrent.futures.thread import ThreadPoolExecutor import riotwatcher try: lol_watcher = riotwatcher.LolWatcher(os.environ["RIOT_API_KEY"]) except KeyError: logging.error("'RIOT_API_KEY' environment variable not found.") exit(1) try: RANKED_QUEUE_NAME = os.environ["RANKED_QUEUE_NAME"] except KeyError: RANKED_QUEUE_NAME = "RANKED_SOLO_5x5" try: SERVERS = os.environ["SERVERS"].split(",") except KeyError: SERVERS = ["KR", "EUW1"] print("Starting masters player parsing") for platform_id in SERVERS: print(f"Starting server {platform_id}") with ThreadPoolExecutor() as executor:
def __init__(self, api_key, region='euw1'): self.watcher = riotwatcher.LolWatcher(api_key) self.region = region
import riotwatcher as rw, pandas as pd, sys, traceback, os def __read_key(filename): file = open(filename, 'r') key = file.readline() file.close() return key key = __read_key('../resources/key') watcher = rw.LolWatcher(key) def add_Account(accounts): new = pd.DataFrame({'AccountName': [str(input('Please enter the summoner name\n'))]}) new = new.set_index('AccountName') new2 = accounts.append(new) return new2 def overview(accounts): for i in accounts.index: print(i) def deleteAccount(accounts): delete = str(input('Which account do you want to delete?\n')) accounts.drop(index=delete, inplace=True) if os.path.isfile('../resources/summoners/' + delete + '.csv'): os.remove('../resources/summoners/' + delete + '.csv')
queue.pop("summonerId") queue.pop("leagueId") players += [dict(queue)] return (missing, players) if __name__ == "__main__": parser = argparse.ArgumentParser(description='ESE Overlord') parser.add_argument('--target-file', required=True) args = parser.parse_args() with open("key.txt", "r") as f: key = f.read().strip() WATCHER = riotwatcher.LolWatcher(key) playersAll = [] with open("players.txt") as f: missing, players = api(f) missing, playersMissed = api(missing) playersAll = playersAll + playersMissed if missing: print("Still missing some players:", missing) players = sorted(playersAll, key=lambda p: p["sorter"], reverse=True) with open(args.target_file, "w") as f: f.write(json.dumps(players, indent=4)) os.chmod(args.target_file, 0o644)