def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = 'b7190b84-484d-4cc7-88ca-8e2b90fb7f56' # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Pull the data for one of Dyrus' matches. match = riotapi.get_match(2034758953) # Create a namedtuple called "Info" that is used to store some information about participants. # We use a namedtuple because it allows for a clear way to access this data later in the script. Info = namedtuple("Info", ["side", "role", "lane"]) # Loop through the participants in this match and record which side they played on (blue or red), # which role they played, and what lane they played in. mapping = {} for participant in match.participants: mapping[participant.champion.name] = Info(participant.side.name, participant.timeline.role.value, participant.timeline.lane.value) print() # Print out the information we just collected. for champion, info in sorted(mapping.items(), key=lambda tuple: (tuple[1].side, tuple[1].lane)): print("{0}: {1}".format(champion, info))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.eager) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password") riotapi.set_data_store(db) master = [entry.summoner for entry in riotapi.get_master()] print("Pulled Master tier. Got {0} summoners.".format(len(master))) gather_start = datetime(2015, 7, 23) # 1 day after patch 5.14 for summoner in master: for match in summoner.match_list(begin_time=gather_start): # If you are connected to a database, the match will automatically be stored in it without you having to do anything. # Simply pull the match, and it's in your database for whenever you need it again! # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot # and therefore will not count against your rate limit. This is true of all datatypes, not just Match. match = get_match(match) print("Stored {0} in my database".format(match)) db.close()
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Pull the data for one of Dyrus' matches. match = riotapi.get_match(2034758953) # Create a namedtuple called "Info" that is used to store some information about participants. # We use a namedtuple because it allows for a clear way to access this data later in the script. Info = namedtuple("Info", ["side", "role", "lane"]) # Loop through the participants in this match and record which side they played on (blue or red), # which role they played, and what lane they played in. mapping = {} for participant in match.participants: mapping[participant.champion.name] = Info( participant.side.name, participant.timeline.role.value, participant.timeline.lane.value) print() # Print out the information we just collected. for champion, info in sorted(mapping.items(), key=lambda tuple: (tuple[1].side, tuple[1].lane)): print("{0}: {1}".format(champion, info))
def setup_cass(): riotapi.set_load_policy("lazy") riotapi.set_rate_limit(25000, 10) riotapi.set_data_store(None) riotapi.set_api_key(os.environ["API_KEY"]) riotapi.set_region("NA") riotapi.print_calls(True)
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.eager) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) # db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password") # riotapi.set_data_store(db) # Gather master names master = [entry.summoner for entry in riotapi.get_challenger()] print("Pulled Master tier. Got {0} summoners.".format(len(master))) gather_start = datetime(2016, 12, 26) gather_end = datetime(2016, 12, 27) for player in master: matches = player.match_list(begin_time=gather_start, end_time=gather_end) matchestoday = len(matches) print(matchestoday) for match in matches: for participant in match.participants: print(participant.champion.name)
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) # db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password") # riotapi.set_data_store(db) master = [entry.summoner for entry in riotapi.get_master()] print("Pulled Master tier. Got {0} summoners.".format(len(master))) gather_start = datetime(2016, 2, 23) # 1 day after patch 5.14 for summoner in master: for match in summoner.match_list(begin_time=gather_start): # If you are connected to a database, the match will automatically be stored in it without you having to do anything. # Simply pull the match, and it's in your database for whenever you need it again! # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot # and therefore will not count against your rate limit. This is true of all datatypes, not just Match. match = get_match(match) print("Stored {0} in my database".format(match))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.eager) gigglepuss = riotapi.get_summoner_by_name("GigglePuss") match_list = riotapi.get_match_list(gigglepuss) sub_list = match_list[:10] matchid = [] versionpatch = [] maptype = [] queue = [] p1name = [] p1side = [] p1champ = [] p1lane = [] p1role = [] p1gold = [] p1win = [] for i in range(len(sub_list)): match = riotapi.get_match(match_list[i]) matchid.append(match.id) versionpatch.append(match.version) maptype.append(match.map) queue.append(match.queue) p1name.append(match.participants[0].summoner_name) p1side.append(match.participants[0].side) p1champ.append(match.participants[0].champion.name) p1lane.append(match.participants[0].timeline.lane) p1role.append(match.participants[0].timeline.role) p1gold.append(match.participants[0].stats.gold_earned) p1win.append(match.participants[0].stats.win) filename = "test_data.csv" columns = ['matchid', 'versionpatch', 'maptype', 'queue', 'p1name', 'p1side', 'p1champ', 'p1lane', 'p1role', 'p1gold', 'p1win'] df = pd.DataFrame([matchid, versionpatch, maptype, queue, p1name, p1side, p1champ, p1lane, p1role, p1gold, p1win], index = columns) df = df.T df.to_csv(filename) print(df)
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) champions = riotapi.get_champions() mapping = {champion.name for champion in champions} print(mapping)
def setup_cassiopeia(region="NA", print_calls=True, key="development"): from cassiopeia import riotapi riotapi.set_region(region) riotapi.print_calls(print_calls) key = key.lower() riotapi.set_load_policy('lazy') if key in ("d", "dev", "development"): key = os.environ['DEV_KEY'] elif key in ("p", "prod", "production"): key = os.environ["PROD_KEY"] riotapi.set_rate_limits((3000, 10), (180000, 600)) riotapi.set_api_key(key) riotapi.set_locale(locale="en_US")
def main(): # Setup riotapi riotapi.set_region(REGION) riotapi.print_calls(True) key = #redacted # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) db = SQLAlchemyDB("sqlite", host="", database=OUTFILE, username="", password="") riotapi.set_data_store(db) # We will seed with all the summoners in Master's tier unpulled_summoners = deque(entry.summoner for entry in riotapi.get_master()) print("Pulled Master tier for seeding. Got {0} summoners.".format(len(unpulled_summoners))) # We need this so that we don't get a recursive loop of summoners pulled_summoners = deque() gather_start = datetime(2015, 1, 1) # since we have data for all of 2015 times_crashed = 0 #store number of times we've had the NoneType error times_looped = 0 #store number of times we've made a call as a rough proxy for when to stop the script while len(unpulled_summoners) > 0: summoner = unpulled_summoners.popleft() for match_reference in summoner.match_list(begin_time=gather_start): # If you are connected to a database, the match will automatically be stored in it without you having to do anything. # Simply pull the match, and it's in your database for whenever you need it again! # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot # and therefore will not count against your rate limit. This is true of all datatypes, include Summoner. match = riotapi.get_match(match_reference) if match is None: # If the match still fails to load, continue on to the next one continue print("Stored {0} in my database".format(match)) for participant in match.participants: try: if participant.summoner not in unpulled_summoners and participant.summoner not in pulled_summoners: unpulled_summoners.append(participant.summoner) except TypeError: times_crashed += 1 print("I've run into the NoneType error {} times so far!".format(times_crashed)) pass times_looped += 1 print("I have now looped {} times.".format(times_looped)) if times_looped > LOOPS: exit("I have looped {} times and am done now.".format(times_looped)) pulled_summoners.append(summoner) db.close()
def main(): db = MySQLdb.connect(host="localhost", user="******", passwd="1234", db="lol") cursor = db.cursor() db.autocommit(True) # Autocommit INSERTs to spotify DB db.set_character_set('utf8') cursor.execute('SET NAMES utf8;') cursor.execute('SET CHARACTER SET utf8;') cursor.execute('SET character_set_connection=utf8;') # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = os.environ[ "DEV_KEY2"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Get total masteries cursor.execute("SELECT id FROM Summoner") summoners = list(cursor) for (summoner, ) in summoners: cursor.execute( "SELECT EXISTS (SELECT * FROM SummonerMasteries WHERE summId = %s)", [summoner]) is_present = list(cursor)[0][0] if not is_present: cursor.execute( "SELECT region " "FROM MatchParticipant PA, MatchPlayer PL, MatchDetail D " "WHERE PL.summonerId = %s " "AND PL._participant_id = PA._id " "AND PA._match_id = D.matchId", [summoner]) region = list(cursor) if region: region = region[0][0] riotapi.set_region(region) mastery_score = championmasteryapi.get_champion_mastery_score( summoner) else: mastery_score = 0 cursor.execute( "INSERT INTO SummonerMasteries (summId, mastery) VALUES (%s, %s)", (summoner, mastery_score)) cursor.close() db.close()
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) summoner = riotapi.get_summoner_by_name("Dyrus") # SummonerID is 5908 # dyrus = riotapi.get_summoner_by_id(5908) # You could use this as well current_game = riotapi.get_current_game(summoner) if current_game is None: print("{0} is not in-game!".format(summoner)) else: print("{0} is in-game!".format(summoner))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) summoner = riotapi.get_summoner_by_name("Dyrs") # SummonerID is 5908 # dyrus = riotapi.get_summoner_by_id(5908) # You could use this as well current_game = riotapi.get_current_game(summoner) if current_game is None: print("{0} is not in-game!".format(summoner)) else: print("{0} is in-game!".format(summoner))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.eager) gigglepuss = riotapi.get_summoner_by_name("GigglePuss") match_list = riotapi.get_match_list(gigglepuss) match = riotapi.get_match(match_list[0]) print(" Match ID: {0}".format(match.id)) print(" Version/Patch: {0}".format(match.version)) print(" Map: {0}".format(match.map)) print(" Queue: {0}".format(match.queue)) print() # Print participant information (not summoner information) for participant in match.participants: print(" {0}".format(participant.summoner_name)) print(" {0}".format(participant.summoner_id)) print(" Champion: {0}".format(participant.champion.name)) print(" Won: {0}".format(participant.stats.win)) print(" Side: {0}".format(participant.side)) print(" Gold earned: {0}".format(participant.stats.gold_earned)) print(" Lane: {0}".format(participant.timeline.lane)) print(" Role: {0}".format(participant.timeline.role)) matchid = [] versionpatch = [] maptype = [] queue = [] p1name = []
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) dyrus = riotapi.get_summoner_by_name("Dyrus") # SummonerID is 5908 # dyrus = riotapi.get_summoner_by_id(5908) # You could use this as well match_list = riotapi.get_match_list(dyrus) num_matches = 20 kills = 0 deaths = 0 assists = 0 print("Calculating K/D/A from the past {0} matches...".format(num_matches)) for i, match_reference in enumerate(match_list[0:num_matches]): match = riotapi.get_match(match_reference) for participant in match.participants: if participant.summoner_id == dyrus.id: kills += participant.stats.kills deaths += participant.stats.kills assists += participant.stats.assists kda = (kills + assists) / deaths print( "Rolling K/D/A for {0}: {1}/{2}/{3} == {4} over most recent {5} matches" .format(dyrus.name, kills, deaths, assists, round(kda, 3), i + 1)) print("Final average K/D/A: {0}/{1}/{2} == {3} over past {4} matches". format(kills, deaths, assists, round(kda, 3), num_matches)) print() print( "If we want K/D/A we really should be using the /stats/ endpoint, but it seems to be inaccurate or missing key information." ) stats = riotapi.get_stats(dyrus) stats = stats[StatSummaryType.ranked_fives].stats print("Total ranked K/D/A for {0}: {1}/{2}/{3} == {4}".format( dyrus.name, stats.kills, stats.deaths, stats.assists, round(stats.kda, 3)))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) champions = riotapi.get_champions() mapping = {champion.id: champion.name for champion in champions} print(mapping) print() # Annie's champion ID is 1, so this will print "Annie" print(mapping[1])
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) match = riotapi.get_match(2034758953) print("Match start time: {0}".format(match.creation)) print("Match duration: {0}".format(match.duration)) # You can just add them together! print("Match end time: {0}".format(match.creation + match.duration)) print("Match version: {0}".format(match.version))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) match = riotapi.get_match(2034758953) print("Match start time: {0}".format(match.creation)) print("Match duration: {0}".format(match.duration)) # You can just add them together! print("Match end time: {0}".format(match.creation + match.duration)) print("Match version: {0}".format(match.version))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) champions = riotapi.get_champions() mapping = {champion.id: champion.name for champion in champions} print(mapping) print() # Annie's champion ID is 1, so this will print "Annie" print(mapping[1])
def main(): riotapi.set_region("kr") riotapi.print_calls(True) riotapi.set_load_policy(LoadPolicy.lazy) riotapi.set_api_key("d045c326-dc9f-4de4-a463-793944aa6984") db = SQLAlchemyDB("mysql+mysqlconnector", "localhost", "kr_challenger_522", "root", "0123") riotapi.set_data_store(db) challenger = [entry.summoner for entry in list(riotapi.get_challenger()[1:10])] gather_start = datetime(2015, 11, 12) # 1 day after patch 5.19 for summoner in challenger: for match in summoner.match_list(begin_time=gather_start): get_match(match) db.close()
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password") riotapi.set_data_store(db) # We will seed with all the summoners in Master's tier unpulled_summoners = deque(entry.summoner for entry in riotapi.get_master()) print("Pulled Master tier for seeding. Got {0} summoners.".format( len(unpulled_summoners))) # We need this so that we don't get a recursive loop of summoners pulled_summoners = deque() gather_start = datetime(2015, 7, 23) # 1 day after patch 5.14 while len(unpulled_summoners) > 0: summoner = unpulled_summoners.popleft() for match_reference in summoner.match_list(begin_time=gather_start): # If you are connected to a database, the match will automatically be stored in it without you having to do anything. # Simply pull the match, and it's in your database for whenever you need it again! # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot # and therefore will not count against your rate limit. This is true of all datatypes, include Summoner. match = riotapi.get_match(match_reference) if match is None: # If the match still fails to load, continue on to the next one continue print("Stored {0} in my database".format(match)) for participant in match.participants: if participant.summoner not in unpulled_summoners and participant.summoner not in pulled_summoners: unpulled_summoners.append(participant.summoner) pulled_summoners.append(summoner) db.close()
def main(): riotapi.set_region("kr") riotapi.print_calls(True) riotapi.set_load_policy(LoadPolicy.lazy) riotapi.set_api_key("d045c326-dc9f-4de4-a463-793944aa6984") db = SQLAlchemyDB("mysql+mysqlconnector", "localhost", "kr_challenger_522", "root", "0123") riotapi.set_data_store(db) challenger = [ entry.summoner for entry in list(riotapi.get_challenger()[1:10]) ] gather_start = datetime(2015, 11, 12) # 1 day after patch 5.19 for summoner in challenger: for match in summoner.match_list(begin_time=gather_start): get_match(match) db.close()
def main(): # Setup riotapi riotapi.set_region("KR") riotapi.print_calls(True) key = os.environ["DEV_KEY1"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) db = SQLAlchemyDB("mysql+mysqlconnector", "localhost", "lol", "root", "1234") riotapi.set_data_store(db) #riotapi.get_masteries() #riotapi.get_champions() #riotapi.get_runes() #riotapi.get_summoner_spells() # We will seed with all the summoners in Master's tier unpulled_summoners = deque(entry.summoner for entry in riotapi.get_master()) print("Pulled Master tier for seeding. Got {0} summoners.".format(len(unpulled_summoners))) # We need this so that we don't get a recursive loop of summoners pulled_summoners = deque() gather_start = datetime(2017, 1, 12) # 1 day after patch 7.1 while len(unpulled_summoners) > 0: summoner = unpulled_summoners.popleft() for match_reference in summoner.match_list(begin_time=gather_start): match = riotapi.get_match(match_reference) if match is None: # If the match still fails to load, continue on to the next one continue print("Stored {0} in my database".format(match)) for participant in match.participants: # cm = riotapi.get_champion_mastery(participant.summoner, participant.champion) if participant.summoner not in unpulled_summoners and participant.summoner not in pulled_summoners: unpulled_summoners.append(participant.summoner) pulled_summoners.append(summoner) db.close()
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) gigglepuss = riotapi.get_summoner_by_name("GigglePuss") # SummonerID is 5908 # dyrus = riotapi.get_summoner_by_id(5908) # You could use this as well match_list = riotapi.get_match_list(gigglepuss) num_matches = 20 kills = 0 deaths = 0 assists = 0 print("Calculating K/D/A from the past {0} matches...".format(num_matches)) for i, match_reference in enumerate(match_list[0:num_matches]): match = riotapi.get_match(match_reference) for participant in match.participants: if participant.summoner_id == gigglepuss.id: kills += participant.stats.kills deaths += participant.stats.kills assists += participant.stats.assists kda = (kills + assists) / deaths print("Rolling K/D/A for {0}: {1}/{2}/{3} == {4} over most recent {5} matches".format(gigglepuss.name, kills, deaths, assists, round(kda, 3), i + 1)) print("Final average K/D/A: {0}/{1}/{2} == {3} over past {4} matches".format(kills, deaths, assists, round(kda, 3), num_matches)) print() print("If we want K/D/A we really should be using the /stats/ endpoint, but it seems to be inaccurate or missing key information.") stats = riotapi.get_stats(gigglepuss) stats = stats[StatSummaryType.ranked_fives].stats print("Total ranked K/D/A for {0}: {1}/{2}/{3} == {4}".format(gigglepuss.name, stats.kills, stats.deaths, stats.assists, round(stats.kda, 3)))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) gigglepuss = riotapi.get_summoner_by_name("GigglePuss") # SummonerID is 5908 match_list = riotapi.get_match_list(gigglepuss) match = riotapi.get_match(match_list[0]) print("Basic match information:") print(" Match ID: {0}".format(match.id)) print(" Version/Patch: {0}".format(match.version)) print(" Creation date: {0} (which was {1} ago)".format(match.creation, datetime.datetime.now() - match.creation)) print(" Duration: {0}".format(match.duration)) print(" Map: {0}".format(match.map)) print(" Mode: {0}".format(match.mode)) print(" Type: {0}".format(match.type)) print(" Platform: {0}".format(match.platform)) print(" Queue: {0}".format(match.queue)) print(" Region: {0}".format(match.region)) print(" Season: {0}".format(match.season)) print(" Red Team Bans: {0}".format([ban.champion.name for ban in match.red_team.bans])) print(" Blue Team Bans: {0}".format([ban.champion.name for ban in match.blue_team.bans])) print() champion = match.participants["GigglePuss"].champion print("You can use special key-words/key-objects to lookup the participants in the match.") print(" Lookup via Summoner: {0}".format(match.participants[gigglepuss])) print(" Lookup via summoner name: {0}".format(match.participants["GigglePuss"])) print(" Lookup via Champion played: {0}".format(match.participants[champion])) print(" Lookup via champion name: {0}".format(match.participants[champion.name]))
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(True) key = os.environ[ "DEV_KEY" ] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password") riotapi.set_data_store(db) # We will seed with all the summoners in Master's tier unpulled_summoners = deque(entry.summoner for entry in riotapi.get_master()) print("Pulled Master tier for seeding. Got {0} summoners.".format(len(unpulled_summoners))) # We need this so that we don't get a recursive loop of summoners pulled_summoners = deque() gather_start = datetime(2015, 7, 23) # 1 day after patch 5.14 while len(unpulled_summoners) > 0: summoner = unpulled_summoners.popleft() for match_reference in summoner.match_list(begin_time=gather_start): # If you are connected to a database, the match will automatically be stored in it without you having to do anything. # Simply pull the match, and it's in your database for whenever you need it again! # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot # and therefore will not count against your rate limit. This is true of all datatypes, include Summoner. match = riotapi.get_match(match_reference) print("Stored {0} in my database".format(match)) for participant in match.participants: if participant.summoner not in unpulled_summoners and participant.summoner not in pulled_summoners: unpulled_summoners.append(participant.summoner) pulled_summoners.append(summoner) db.close()
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ[ "DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.eager) # Load and connect to your database. (Comment this code to use local memory. Don't forget to comment db.close() below too.) # db = SQLAlchemyDB("mysql+mysqlconnector", "databse_hostname", "database_name", "username", "password") # riotapi.set_data_store(db) # Gather master names master = [entry.summoner for entry in riotapi.get_challenger()] mastertests = master print("Pulled Master tier. Got {0} summoners.".format(len(master))) #Make empty lists for match information matchid = [] versionpatch = [] matchdate = [] maptype = [] queue = [] p_names = [] p_sides = [] p_champs = [] p_lanes = [] p_roles = [] p_golds = [] p_wins = [] #Define a start date, and then for each player in the master list, get the match ID number gather_start = datetime(2016, 12, 28, 18) # 1 day after patch 5.14, year month date for summoner in master: for match in summoner.match_list(begin_time=gather_start): # If you are connected to a database, the match will automatically be stored in it without you having to do anything. # Simply pull the match, and it's in your database for whenever you need it again! # If you pull a match twice, the second time it will be loaded from the database rather than pulled from Riot # and therefore will not count against your rate limit. This is true of all datatypes, not just Match. match = get_match(match) print("Got {0}".format(match)) #Then save the match information to some empty lists matchid.append(match.id) versionpatch.append(match.version) matchdate.append(match.creation) maptype.append(match.map) queue.append(match.queue) #Now make empty lists for the player information p1name = [] p1side = [] p1champ = [] p1lane = [] p1role = [] p1gold = [] p1win = [] #Make a loop to get the rest of the participants for part in match.participants: p1name.append(part.summoner_name) p1side.append(part.side) p1champ.append(part.champion.name) p1lane.append(part.timeline.lane) p1role.append(part.timeline.role) p1gold.append(part.stats.gold_earned) p1win.append(part.stats.win) #Save information into the lists p_names.append(p1name) p_sides.append(p1side) p_champs.append(p1champ) p_lanes.append(p1lane) p_roles.append(p1role) p_golds.append(p1gold) p_wins.append(p1win) #db.close() filename = "master_data_28Dec2016.csv" columns = [ 'matchid', 'versionpatch', 'matchdate', 'maptype', 'queue', 'p_names', 'p_sides', 'p_champs', 'p_lanes', 'p_roles', 'p_golds', 'p_wins' ] df = pd.DataFrame([ matchid, versionpatch, matchdate, maptype, queue, p_names, p_sides, p_champs, p_lanes, p_roles, p_golds, p_wins ], index=columns) df = df.T df.to_csv(filename)
def request_data(summoner_request): #Set Riot API information riotapi.set_region("NA") riotapi.print_calls(False) riotapi.set_api_key(os.environ["RIOT_DEV"]) riotapi.set_load_policy(LoadPolicy.lazy) #Establish database connection client = MongoClient( "mongodb://*****:*****@ds135700.mlab.com:35700/summonertest") db = client.summonertest #Declare variables kills = 0 deaths = 0 assists = 0 kda = 0 avg_time = 0 avg_cs = 0 avg_game_cs = 0 avg_time = 0 cs = 0 try: name_request = summoner_request #CHANGE TO DESIRED LOOKUP NAME except: return None summoner = riotapi.get_summoner_by_name(name_request) match_list = summoner.match_list() #Number of matches to pull from Riot Servers num_matches = 5 #CHANGE THIS TO NUMBER INTERESTED IN #Basic stats collection for i, match_reference in enumerate(match_list[0:num_matches]): match = match_reference.match() for participant in match.participants: if participant.summoner_id == summoner.id: cs += participant.stats.cs kills += participant.stats.kills deaths += participant.stats.deaths assists += participant.stats.assists avg_time += match.duration.total_seconds() if (avg_time > 0): avg_cs += (float)(participant.stats.cs / (match.duration.total_seconds() / 60)) #Matchwide averages if (deaths > 0): kda = (float)(kills + assists) / deaths else: kda = kills + assists if (num_matches > 0): avg_time = (float)((avg_time / 60) / num_matches) avg_game_cs = (float)(avg_cs / num_matches) if (avg_time > 0): avg_cs = (float)(cs / num_matches) #TODO Create scores for various items #Verify user not already on server, delete if pre-existing if (db.summoners.count() > 0): if (db.summoners.find({"summoner": summoner.name})): clear = db.summoners.delete_many({"summoner": summoner.name}) #Push to server pushVal = db.summoners.insert_one({ "summoner": summoner.name, "level": summoner.level, "matches_polled": num_matches, "kda": round(kda, 3), "kills": kills, "deaths": deaths, "assists": assists, "average_cs_per_min": round(avg_game_cs, 1), "average_cs": (int)(avg_cs), "average_time": round(avg_time, 2), "date_created": time.asctime(time.localtime(time.time())) }) #TODO Adjust so that data sometimes updates instead of always deleting #Report data on server to console """display = db.summoners.find().sort([
Author: John Cleaver <*****@*****.**> Copyright: 2017 John Cleaver License: MIT (See LICENSE file) """ import os from datetime import datetime from cassiopeia import riotapi from cassiopeia.type.core.common import Queue from cassiopeia.type.api.store import SQLAlchemyDB from cassiopeia.type.api.exception import APIError riotapi.set_region("NA") riotapi.print_calls(True) key = key = os.environ["DEV_KEY"] riotapi.set_api_key(key) current_patch_start = datetime(2017, 3, 22) queue = Queue.flex_threes def auto_retry(api_call_method): """ A decorator to automatically retry 500s (Service Unavailable) and skip 400s (Bad Request) or 404s (Not Found). """ def call_wrapper(*args, **kwargs): try: return api_call_method(*args, **kwargs) except APIError as error: # Try Again Once
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) gigglepuss = riotapi.get_summoner_by_name("GigglePuss") # SummonerID is 5908 match_list = riotapi.get_match_list(gigglepuss) match = riotapi.get_match(match_list[0]) print("Basic match information:") print(" Match ID: {0}".format(match.id)) print(" Version/Patch: {0}".format(match.version)) print(" Creation date: {0} (which was {1} ago)".format(match.creation, datetime.datetime.now() - match.creation)) print(" Duration: {0}".format(match.duration)) print(" Map: {0}".format(match.map)) print(" Mode: {0}".format(match.mode)) print(" Type: {0}".format(match.type)) print(" Platform: {0}".format(match.platform)) print(" Queue: {0}".format(match.queue)) print(" Region: {0}".format(match.region)) print(" Season: {0}".format(match.season)) print(" Red Team Bans: {0}".format([ban.champion.name for ban in match.red_team.bans])) print(" Blue Team Bans: {0}".format([ban.champion.name for ban in match.blue_team.bans])) print() champion = match.participants["GigglePuss"].champion print("You can use special key-words/key-objects to lookup the participants in the match.") print(" Lookup via Summoner: {0}".format(match.participants[gigglepuss])) print(" Lookup via summoner name: {0}".format(match.participants["GigglePuss"])) print(" Lookup via Champion played: {0}".format(match.participants[champion])) print(" Lookup via champion name: {0}".format(match.participants[champion.name])) print() # Print some basic information about the summoners in the game that doesn't require calls to the Summoner API. # If you ask for participant.summoner, Casseopeia will make a call to the Summoner API to get the full summoner information. print("Basic summoner information:") for participant in match.participants: print(" {0} ({1}) played {2}".format(participant.summoner_name, participant.summoner_id, participant.champion.name)) print() # Print participant information (not summoner information) print("Participant information for this match:") for participant in match.participants: print(" {0}".format(participant.summoner_name)) print(" Champion: {0}".format(participant.champion.name)) print(" Won: {0}".format(participant.stats.win)) print(" Side: {0}".format(participant.side)) print(" Kills: {0}".format(participant.stats.kills)) print(" Deaths: {0}".format(participant.stats.deaths)) print(" Assists: {0}".format(participant.stats.assists)) print(" KDA: {0}".format(participant.stats.kda)) print(" CS: {0}".format(participant.stats.cs)) print(" Summoner spells: {0} + {1}".format(participant.summoner_spell_d, participant.summoner_spell_f)) print(" Champion Level: {0}".format(participant.stats.champion_level)) print(" Got first blood: {0}".format(participant.stats.first_blood)) print(" Gold earned: {0}".format(participant.stats.gold_earned)) print(" Gold spent: {0}".format(participant.stats.gold_spent)) print(" Items: {0}".format([item.name if item is not None else None for item in participant.stats.items])) print(" Magic Damage Dealt: {0}".format(participant.stats.magic_damage_dealt)) print(" Physical Damage Dealt: {0}".format(participant.stats.physical_damage_dealt)) print(" Lane: {0}".format(participant.timeline.lane)) print(" Role: {0}".format(participant.timeline.role)) print() print("Timestamp of last frame: {0}".format(match.frames[-1].timestamp)) print("Number of events in last frame: {0}".format(len(match.frames[-1].events))) print("What's up with the bans?")
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.lazy) dyrus = riotapi.get_summoner_by_name("Dyrus") # SummonerID is 5908 match_list = riotapi.get_match_list(dyrus) match = riotapi.get_match(match_list[0]) print("Basic match information:") print(" Match ID: {0}".format(match.id)) print(" Version/Patch: {0}".format(match.version)) print(" Creation date: {0} (which was {1} ago)".format(match.creation, datetime.datetime.now() - match.creation)) print(" Duration: {0}".format(match.duration)) print(" Map: {0}".format(match.map)) print(" Mode: {0}".format(match.mode)) print(" Type: {0}".format(match.type)) print(" Platform: {0}".format(match.platform)) print(" Queue: {0}".format(match.queue)) print(" Region: {0}".format(match.region)) print(" Season: {0}".format(match.season)) print(" Red Team Bans: {0}".format([ban.champion.name for ban in match.red_team.bans])) print(" Blue Team Bans: {0}".format([ban.champion.name for ban in match.blue_team.bans])) print() champion = match.participants["Dyrus"].champion print("You can use special key-words/key-objects to lookup the participants in the match.") print(" Lookup via Summoner: {0}".format(match.participants[dyrus])) print(" Lookup via summoner name: {0}".format(match.participants["Dyrus"])) print(" Lookup via Champion played: {0}".format(match.participants[champion])) print(" Lookup via champion name: {0}".format(match.participants[champion.name])) print() # Print some basic information about the summoners in the game that doesn't require calls to the Summoner API. # If you ask for participant.summoner, Casseopeia will make a call to the Summoner API to get the full summoner information. print("Basic summoner information:") for participant in match.participants: print(" {0} ({1}) played {2}".format(participant.summoner_name, participant.summoner_id, participant.champion.name)) print() # Print participant information (not summoner information) print("Participant information for this match:") for participant in match.participants: print(" {0}".format(participant.summoner_name)) print(" Champion: {0}".format(participant.champion.name)) print(" Won: {0}".format(participant.stats.win)) print(" Side: {0}".format(participant.side)) print(" Kills: {0}".format(participant.stats.kills)) print(" Deaths: {0}".format(participant.stats.deaths)) print(" Assists: {0}".format(participant.stats.assists)) print(" KDA: {0}".format(participant.stats.kda)) print(" CS: {0}".format(participant.stats.cs)) print(" Summoner spells: {0} + {1}".format(participant.summoner_spell_d, participant.summoner_spell_f)) print(" Champion Level: {0}".format(participant.stats.champion_level)) print(" Got first blood: {0}".format(participant.stats.first_blood)) print(" Gold earned: {0}".format(participant.stats.gold_earned)) print(" Gold spent: {0}".format(participant.stats.gold_spent)) print(" Items: {0}".format([item.name if item is not None else None for item in participant.stats.items])) print(" Magic Damage Dealt: {0}".format(participant.stats.magic_damage_dealt)) print(" Physical Damage Dealt: {0}".format(participant.stats.physical_damage_dealt)) print(" Lane: {0}".format(participant.timeline.lane)) print(" Role: {0}".format(participant.timeline.role)) print() print("Timestamp of last frame: {0}".format(match.frames[-1].timestamp)) print("Number of events in last frame: {0}".format(len(match.frames[-1].events)))
def cards(request): if request.GET: riotapi.set_api_key("3ca655bb-959d-4ed3-ab2c-287da159aa59") riotapi.set_rate_limits((1500, 10), (90000, 600)) getted = request.GET summoner = getted.get('summ') region = getted.get('region') riotapi.set_region(region) riotapi.print_calls(True) try: summ = riotapi.get_summoner_by_name(summoner) except APIError: return HttpResponseRedirect('/dorans/') masteries = riotapi.get_champion_masteries(summ) trophyChampions = {} count = 0 #this sets up so that champions with lvl 4 or higher mastery but if less than 4 are found add more from lower lvls for champion, mastery in masteries.items(): if mastery.level >= 4 : trophyChampions[champion] = mastery count = count + 1 if count < 4: for champion, mastery in masteries.items(): if mastery.level == 3 : trophyChampions[champion] = mastery displayChampions = [] summid = riotapi.get_summoner_by_name(summoner).id for c in trophyChampions: print(c) topKDA = 0 kills = 0 deaths = 0 assists = 0 wins = 0 losses = 0 MVP = 0 try: matches = riotapi.get_match_list(summ,champions = c, seasons="SEASON2016") except APIError: matches = riotapi.get_match_list(summ,champions = c, seasons="SEASON2016") if not matches: continue for m in matches: try: data = riotapi.get_match(m, include_timeline = False) except APIError: continue teamtotal = 0 tgold = 0 tdamagedlt = 0 tdamagetkn = 0 twards = 0 twardkls = 0 for player in data.participants: if player.summoner_id == summid: #Build stats from this players participant object i = 0 if player.side.name == 'blue': for p in data.participants: i +=1 if i < 5: teamtotal += p.stats.kills tgold += p.stats.gold_earned tdamagedlt += p.stats.damage_dealt_to_champions tdamagetkn += p.stats.damage_taken twards += p.stats.wards_placed else: for p in data.participants: i += 1 if i >= 5: teamtotal += p.stats.kills tgold += p.stats.gold_earned tdamagedlt += p.stats.damage_dealt_to_champions tdamagetkn += p.stats.damage_taken twards += p.stats.wards_placed if teamtotal == 0 : teamtotal = 1; if twards == 0: twards == 1; topKDA = player.stats.kda if player.stats.kda > topKDA else topKDA kills += player.stats.kills deaths += player.stats.deaths assists += player.stats.assists trip = player.stats.triple_kills quad = player.stats.quadra_kills penta = player.stats.penta_kills kp = player.stats.kills/teamtotal g = player.stats.gold_earned/tgold cs = player.stats.cs/data.duration.seconds dmgdlt = player.stats.damage_dealt_to_champions/tdamagedlt dmgtkn = player.stats.damage_taken/tdamagetkn wards = player.stats.wards_placed/twards kda = player.stats.kda if kda == 1: kda = 1.1 if kda == 0: try: kda = .01/p.stats.deaths except ZeroDivisionError: kda = .1 if p.timeline.role.name == 'solo': if p.timeline.lane.name == 'mid_lane': #mid MVP += math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 12) + (dmgtkn * -1) + (wards *4) ) + trip * .25 + quad * .5 + penta * 1 else: #print(math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 7) + (dmgtkn * 7) + (wards *4) )) MVP += math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 7) + (dmgtkn * 7) + (wards *4) ) + trip * .25 + quad * .5 + penta * 1 elif p.timeline.role.name == 'carry':# carry #print(math.log(kda)/math.log(6) * ((kp * 10)+(g * 6)+(cs * .7)+ (dmgdlt * 12) + (dmgtkn * 1) + (wards *1) )) MVP += math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 12) + (dmgtkn * -1) + (wards *4) )+ trip * .25 + quad * .5 + penta * 1 elif p.timeline.role.name == 'support': #supp #print(math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 7) + (dmgtkn * 7) + (wards *6) )) MVP += math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * 1.0)+ (dmgdlt * 6) + (dmgtkn * 7) + (wards *5) )+ trip * .25 + quad * .5 + penta * 1 elif p.timeline.role.name == 'none': #jungle #print(math.log(kda)/math.log(6)) MVP += math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 7) + (dmgtkn * 7) + (wards *4) )+ trip * .25 + quad * .5 + penta * 1 else: #unknown duo setup #print(math.log(kda)/math.log(6)) MVP += math.log(kda)/math.log(6) * ((kp * 10)+(g * 5)+(cs * .7)+ (dmgdlt * 10) + (dmgtkn * 2) + (wards *4) ) + trip * .25 + quad * .5 + penta * 1 if player.stats.win: wins = wins + 1 else: losses = losses + 1 championStats = {} championStats['level'] = masteries[c].level championStats['topGrade'] = masteries[c].highest_grade championStats['points'] = masteries[c].points championStats['topKDA'] = round(topKDA, 2) if deaths == 0: deaths = 1 championStats['KDA'] = round((kills + assists) / deaths , 2) championStats['avgkills'] = round(kills / (wins+ losses), 2) championStats['avgdeaths'] = round(deaths / (wins+ losses), 2) championStats['avgassists'] = round(assists / (wins+ losses), 2) championStats['avgMVP'] = round(MVP / (wins + losses), 2) championStats['wins'] = wins championStats['losses'] = losses imagep = c.image.link imagep = imagep.split('.') image = 'http://ddragon.leagueoflegends.com/cdn/img/champion/loading/' + imagep[0] + '_0.jpg' displayChampions.append({'name':str(c), 'stats':championStats, 'mastery': masteries[c], 'masterypoint':masteries[c].points, 'image': image }) displayChampions = sorted(displayChampions, key=itemgetter('masterypoint'), reverse=True) return HttpResponse(render(request, 'doranscards.html', {'champions' : displayChampions})) else: return HttpResponseRedirect('/dorans/')
def on_load(bot): riotapi.set_region("NA") riotapi.print_calls(False) riotapi.set_api_key(environ.get("RIOT_API")) riotapi.set_load_policy(LoadPolicy.lazy)
import os import datetime from cassiopeia import riotapi from cassiopeia import baseriotapi from cassiopeia.type.core.common import LoadPolicy import json import heapq riotapi.set_region("EUW") riotapi.print_calls(False) key = "deef6b4f-d2b2-49a1-8aaf-9128a2fc54e3" # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy("eager") summoner = riotapi.get_summoner_by_name("bynikiyo") lista = riotapi.get_ranked_stats(summoner,season=None) dictionary = {} wins = [] for key,value in lista.items(): if str(key) != 'None': sumka = value.assists + value.kills wins.append(value.games_played) listData = [value.games_played,value.assists,value.kills,value.deaths,value.minions_killed,sumka] champ = riotapi.get_champion_by_name(str(key)) dictionary[champ] = listData bestof = heapq.nlargest(5,wins) final = {} for key,value in dictionary.items(): for item in bestof: if str(item) == str(value[0]):
def main(): # Setup riotapi riotapi.set_region("NA") riotapi.print_calls(False) os.environ["DEV_KEY"] = "94e831f6-ef9f-4823-81fc-cfc9342f4428" key = os.environ["DEV_KEY"] # You can create an env var called "DEV_KEY" that holds your developer key. It will be loaded here. riotapi.set_api_key(key) riotapi.set_load_policy(LoadPolicy.eager) gigglepuss = riotapi.get_summoner_by_name("GigglePuss") match_list = riotapi.get_match_list(gigglepuss) sub_list = match_list[:10] matchid = [] versionpatch = [] maptype = [] queue = [] p_names = [] p_sides = [] p_champs = [] p_lanes = [] p_roles = [] p_golds = [] p_wins= [] for i in range(len(sub_list)): match = riotapi.get_match(match_list[i]) matchid.append(match.id) versionpatch.append(match.version) maptype.append(match.map) queue.append(match.queue) p1name = [] p1side = [] p1champ = [] p1lane = [] p1role = [] p1gold = [] p1win = [] for part in match.participants: print(part.summoner_name) p1name.append(part.summoner_name) p1side.append(part.side) p1champ.append(part.champion.name) p1lane.append(part.timeline.lane) p1role.append(part.timeline.role) p1gold.append(part.stats.gold_earned) p1win.append(part.stats.win) p_names.append(p1name) p_sides.append(p1side) p_champs.append(p1champ) p_lanes.append(p1lane) p_roles.append(p1role) p_golds.append(p1gold) p_wins.append(p1win) filename = "test_data.csv" columns = ['matchid', 'versionpatch', 'maptype', 'queue', 'p_names', 'p_sides', 'p_champs', 'p_lanes', 'p_roles', 'p_golds', 'p_wins'] df = pd.DataFrame([matchid, versionpatch, maptype, queue, p_names, p_sides, p_champs, p_lanes, p_roles, p_golds, p_wins], index = columns) df = df.T df.to_csv(filename) print(df)
items = ["Stalker's Blade - Cinderhulk", "Mercury's Treads - Alacrity", "Dead Man's Plate", "Banshee's Veil", 'Abyssal Scepter', "Liandry's Torment"] build = Build(champion='Amumu', level=18, item_set=items, rune_page=rp, mastery_page=mp) return build def Thresh(): mp = {6311: 5, 6322: 1, 6332: 5, 6342: 1, 6211: 5, 6223: 1, 6232: 5, 6241: 1, 6251: 5, 6263: 1} rp = {5317: 9, 5245: 9, 5289: 9, 5296: 3} items = [3111, 3097, 1011] build = Build(champion=412, level=5, item_set=items, rune_page=rp, mastery_page=mp) return build if __name__ == '__main__': riotapi.set_api_key(os.environ['DEV_KEY']) riotapi.print_calls(True) riotapi.set_region('NA') try: champ = sys.argv[1].lower() except IndexError: champ = 'jinx' if champ == 'jinx': build = Jinx() elif champ == 'annie': build = Annie() elif champ == 'amumu': build = Amumu() elif champ == 'thresh': build = Thresh()