コード例 #1
0
def getSummonerMatchList(summonerId, server, queue, season):
	key = readApiKey()
	w = RiotWatcher(key, server)
	try:
		info = w.get_match_list(summonerId, server, champion_ids=None, #Aqui obtiene las partidas jugadasde un jugador (son muchas)
                          ranked_queues=queue,
                          season=season)
	except Exception:
		pass

	return info['matches']
コード例 #2
0
class LeagueGrind(object):
	
	def __init__(self, spreadSheetName):
		# Establish Google Drive Connection
		json_key = json.load(open('credentials.json'))
		scope = ['https://spreadsheets.google.com/feeds']
		credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)
		gc = gspread.authorize(credentials)
		self.spreadsheet = gc.open("League Grinds")		
		
		#Establish Riot API Connection
		self.riotWatcher = RiotWatcher(getDevKey())		
		
	def update_player(self, playerName):
		
		# Get the current spread sheet for playerName
		# If it does not exist, create one for them
		try:		
			worksheet = self.spreadsheet.worksheet("API-"+playerName)
		except:		
			self.spreadsheet.add_worksheet("API-"+playerName,1,8)
			worksheet = self.spreadsheet.worksheet("API-"+playerName)
			self.init_player_spreadsheet(worksheet)
		
		# Determine Last Entered Match
		rows = worksheet.row_count
		if rows == 1:	lastTimeStamp = 0
		else: 			lastTimeStamp = worksheet.cell(rows,2).value
		
		# Get Summoner ID
		while self.riotWatcher.can_make_request() == False:
			continue
		player = self.riotWatcher.get_summoner(name=playerName)
		playerID = player['id']
		
		# Request Match Meta Data
		while self.riotWatcher.can_make_request() == False:
			continue
		match_list = self.riotWatcher.get_match_list(playerID,region='na',season='SEASON2016')
		
		# Send all new Matches to SpreadSheet
		for f in match_list['matches'][::-1]:
			if f['timestamp'] > int(lastTimeStamp):
				Match(playerID,self.riotWatcher,f).log(worksheet)
				
	def init_player_spreadsheet(self,worksheet):
		worksheet.update_cell(1,1,"MatchID")
		worksheet.update_cell(1,2,"Timestamp")
		worksheet.update_cell(1,3,"Champion")
		worksheet.update_cell(1,4,"Kills")
		worksheet.update_cell(1,5,"Deaths")
		worksheet.update_cell(1,6,"Assists")
		worksheet.update_cell(1,7,"KDA")
		worksheet.update_cell(1,8,"Outcome")		
コード例 #3
0
def main():
    p_ids = []
    with open('player_tiers.csv') as csvfile:
        reader = csv.DictReader(csvfile)
        p_ids = [row['user_id'] for row in reader if row['tier'] == 'SILVER']

    db = sqlite3.connect('matchdb')
    cursor = db.cursor()
    cursor.execute("""
        CREATE TABLE IF NOT EXISTS match_by_tier(
            user_id INTEGER KEY,
            match_id INTEGER KEY,
            tier VARCHAR(255),
            UNIQUE (user_id, match_id) ON CONFLICT REPLACE);
    """)
    db.commit()
    db.close()

    w = RiotWatcher(constants.riot_id)
    db = sqlite3.connect('matchdb')
    cursor = db.cursor()

    curTime = long(time.time() * 1000)

    for user_id in p_ids:
        cursor.execute(
            '''SELECT DISTINCT user_id FROM match_by_tier WHERE user_id=?''',
            (user_id, ))
        if (cursor.fetchone() is None):
            match_list = []
            try:
                match_list = w.get_match_list(
                    str(user_id),
                    region=NORTH_AMERICA,
                    begin_time=curTime - 1000 * 60 * 60 * 24 * 30,
                    end_time=curTime,
                )['matches']
            except Exception as e:
                print(e)
            filtered_matches = [
                m for m in match_list if m['queue'] == 'RANKED_SOLO_5x5'
            ]
            retVal = filtered_matches[:10]
            time.sleep(2)
            user_matches = [(user_id, m['matchId'], 'SILVER') for m in retVal]
            cursor.executemany(
                '''INSERT INTO match_by_tier (user_id, match_id, tier) VALUES (?,?, ?)''',
                user_matches)
            db.commit()
            print("Dealt with {0}".format(user_id))
        else:
            print("Skipped {0}".format(user_id))
    db.close()
コード例 #4
0
def getSummonerMatchList(summonerId, server, queue, season):
    key = readApiKey()
    w = RiotWatcher(key, server)
    try:
        info = w.get_match_list(
            summonerId,
            server,
            champion_ids=
            None,  #Aqui obtiene las partidas jugadasde un jugador (son muchas)
            ranked_queues=queue,
            season=season)
    except Exception:
        pass

    return info['matches']
コード例 #5
0
def main():
    p_ids = []
    with open("player_tiers.csv") as csvfile:
        reader = csv.DictReader(csvfile)
        p_ids = [row["user_id"] for row in reader if row["tier"] == "SILVER"]

    db = sqlite3.connect("matchdb")
    cursor = db.cursor()
    cursor.execute(
        """
        CREATE TABLE IF NOT EXISTS match_by_tier(
            user_id INTEGER KEY,
            match_id INTEGER KEY,
            tier VARCHAR(255),
            UNIQUE (user_id, match_id) ON CONFLICT REPLACE);
    """
    )
    db.commit()
    db.close()

    w = RiotWatcher(constants.riot_id)
    db = sqlite3.connect("matchdb")
    cursor = db.cursor()

    curTime = long(time.time() * 1000)

    for user_id in p_ids:
        cursor.execute("""SELECT DISTINCT user_id FROM match_by_tier WHERE user_id=?""", (user_id,))
        if cursor.fetchone() is None:
            match_list = []
            try:
                match_list = w.get_match_list(
                    str(user_id), region=NORTH_AMERICA, begin_time=curTime - 1000 * 60 * 60 * 24 * 30, end_time=curTime
                )["matches"]
            except Exception as e:
                print(e)
            filtered_matches = [m for m in match_list if m["queue"] == "RANKED_SOLO_5x5"]
            retVal = filtered_matches[:10]
            time.sleep(2)
            user_matches = [(user_id, m["matchId"], "SILVER") for m in retVal]
            cursor.executemany("""INSERT INTO match_by_tier (user_id, match_id, tier) VALUES (?,?, ?)""", user_matches)
            db.commit()
            print("Dealt with {0}".format(user_id))
        else:
            print("Skipped {0}".format(user_id))
    db.close()
コード例 #6
0
class LeagueGrind(object):
	
	def __init__(self, spreadSheetName):
		# Establish Google Drive Connection
		json_key = json.load(open('credentials.json'))
		scope = ['https://spreadsheets.google.com/feeds']
		credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope)
		gc = gspread.authorize(credentials)
		self.spreadsheet = gc.open("League Grinds")
		
		#Establish Riot API Connection
		self.riotWatcher = RiotWatcher(getDevKey())		
		
	def update_player(self, playerName):
		player = self.riotWatcher.get_summoner(name=playerName)
		playerID = player['id']
		match_list = self.riotWatcher.get_match_list(playerID,region='na',season='SEASON2016')
		
		if raw_input("Get Match Data? yes/no\n") == "yes":
			matches = [Match(playerID,self.riotWatcher,f) for f in match_list['matches']]
コード例 #7
0
ファイル: get_data.py プロジェクト: simejanko/diplomska-lol
    pulled_matches_count += 1
    os.remove('game_data_{0}.pkl'.format(saved_files))

    saved_files += 1

while True:
    if len(unpulled_summoners) == 0:
        #if we run out of summoners, hopefully older summoners already played new matches
        unpulled_summoners = random.sample(pulled_summoners, 15)
        pulled_summoners = list()

    current_summoner_id = unpulled_summoners.pop(0)

    try:
        wait_for_request_availability(w)
        match_history = w.get_match_list(current_summoner_id, season='SEASON2016',ranked_queues=('RANKED_SOLO_5x5', 'TEAM_BUILDER_DRAFT_RANKED_5x5') , begin_index=0, end_index=15)
    except Exception,e:
            print("An ERROR occurred when pulling match history data for summonerId {0}! {1}".format(current_summoner_id,e))
            unpulled_summoners.insert(0, current_summoner_id)
            continue
    try:
        matchIdsToTimestamp = { match['matchId']:match['timestamp'] for match in match_history['matches'] }
    except KeyError,e:
        print("Some field you tried to access did not exist in the pulled summoner data: {0}".format(e))
        continue

    pulled_summoners.append(current_summoner_id)
    for matchId, timestamp in matchIdsToTimestamp.items():
        if matchId not in pulled_matches and timestamp > int(time.time()*1000) - 3*24*60*60000:
            try:
                wait_for_request_availability(w)
コード例 #8
0
ファイル: Main.py プロジェクト: SaahilClaypool/RiotAnalysis
from riotwatcher import RiotWatcher
import json
w = RiotWatcher('21e6bb30-08e1-47ed-946f-cee514b740d8')

# check if we have API calls remaining
print(w.can_make_request())

me = w.get_summoner(name='Lustboy')
#print(me)

# takes list of summoner ids as argument, supports up to 40 at a time
# (limit enforced on riot's side, no warning from code)
#my_mastery_pages = w.get_mastery_pages([me['id'], ])[str(me['id'])]
#print(my_mastery_pages)s
recentGames = w.get_match_list(me['id'])['matches']

print(json.dumps(recentGames))

lane15 = {
    "DUO_CARRY": float(0),
    "DUO": float(0),
    "DUO_SUPPORT": float(0),
    "MID": float(0),
    "JUNGLE": float(0),
    "TOP": float(0),
    "SOLO": float(0)
}
lane13 = {
    "DUO_CARRY": float(0),
    "DUO": float(0),
    "DUO_SUPPORT": float(0),
コード例 #9
0
    saved_files += 1

while True:
    if len(unpulled_summoners) == 0:
        #if we run out of summoners, hopefully older summoners already played new matches
        unpulled_summoners = random.sample(pulled_summoners, 15)
        pulled_summoners = list()

    current_summoner_id = unpulled_summoners.pop(0)

    try:
        wait_for_request_availability(w)
        match_history = w.get_match_list(
            current_summoner_id,
            season='SEASON2016',
            ranked_queues=('RANKED_SOLO_5x5', 'TEAM_BUILDER_DRAFT_RANKED_5x5'),
            begin_index=0,
            end_index=15)
    except Exception, e:
        print(
            "An ERROR occurred when pulling match history data for summonerId {0}! {1}"
            .format(current_summoner_id, e))
        unpulled_summoners.insert(0, current_summoner_id)
        continue
    try:
        matchIdsToTimestamp = {
            match['matchId']: match['timestamp']
            for match in match_history['matches']
        }
    except KeyError, e:
        print(