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(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(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()
Beispiel #4
0
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()
Beispiel #5
0
async def on_message(bot, msg, msg_obj):
    if msg[0] == 'summoner':
        summoner = riotapi.get_summoner_by_name(' '.join(msg[1:]))
        print(summoner)
        match_list = summoner.match_list()
        first = match_list[0].match()

        player = first.participants[summoner]

        await bot.send_message(
            msg_obj.channel,
            '%s %s his last game in %s lane, role: %s.\nChampion: %s | Kills: %s | Deaths: %s | Assists: %s | CS: %s | KDA: %s\nBans: %s'
            % (msg[1], "won" if player.stats.win else "lost",
               player.timeline.lane, player.timeline.role,
               player.champion.name, player.stats.kills, player.stats.deaths,
               player.stats.assists, player.stats.cs, player.stats.kda,
               ('/'.join([
                   ban.champion.name
                   for ban in first.red_team.bans + first.blue_team.bans
               ]))))
        return True

    if msg[0] == 'master':
        master = [entry.summoner for entry in riotapi.get_master()]

        for summoner in master:
            if master.name.lower() == ' '.join(msg[1:]).lower():
                await bot.send_message(msg_obj.channel,
                                       '**YOU THINK THAT PLAYER IS A JOKE?**')

        await bot.send_message(msg_obj.channel,
                               'No, that player is basically johnny...')
        return True

    if msg[0] == 'mmr':
        summoner = ''.join(msg[1:])

        mmr = await get_mmr(summoner)
        await bot.send_message(
            msg_obj.channel, '**%s** has an MMR of: *%s*\n%s\n`%s`' %
            (summoner, mmr['value'], mmr['tip'], mmr['average']))
        return True
Beispiel #6
0
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(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()
Beispiel #8
0
def get_summoners():
    summoners = [entry.summoner for entry in riotapi.get_master(queue)]
    summoners.extend(
        [entry.summoner for entry in riotapi.get_challenger(queue)])

    return summoners
Beispiel #9
0
def test_master():
    int_test_handler.test_result(riotapi.get_master())
Beispiel #10
0
def test_master():
    int_test_handler.test_result(riotapi.get_master())
Beispiel #11
0
riotapi.set_region("KR")
riotapi.set_api_key("79428a9e-5d98-469b-9b9b-429c1a750d24")
riotapi.set_rate_limits((10, 10), (500, 600))
riotapi.print_calls(True)

#%% 

client = MongoClient()
loladb = client.loladb73
summoners_collection = loladb.summoners
matches_collection = loladb.matches

if summoners_collection.count() == 0:
    #Save summoner information to mongodb
    masters = riotapi.get_master()
    challengers = riotapi.get_challenger()
    summoners_collection.insert_many([json.loads(entry.to_json()) for entry in masters.data.entries])
    summoners_collection.insert_many([json.loads(entry.to_json()) for entry in challengers.data.entries])
    
summoner_count = summoners_collection.count()
print summoner_count
print matches_collection.count()

#%% 

def RecordSummonerLatestMatchId(summoner, matchId):
    summoners_collection.update_one({'playerOrTeamId':str(summoner.id)}, {'$set': {'latestGrabbedMatchId': matchId}})

def RecordSummonerForFullGrab(summoner):
    summoners_collection.update_one({'playerOrTeamId':str(summoner.id)}, {'$set': {'fullGrabbed': True}})