Пример #1
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.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()
Пример #2
0
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():
  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()
Пример #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()
Пример #5
0
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()
Пример #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()
Пример #7
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)
            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()
Пример #8
0
def summoner(summ):

    summ = summ.replace(" ", "")

    # regionlist = [zone.value for zone in Region]
    regionlist = ['na', 'kr', 'euw', 'eune']
    zone_summoners = []

    # Try to speed this up by using pure riot json requests simultaneously for all regions?
    for r in regionlist:

        cassdb = SQLAlchemyDB(connector, host, dbnames[r]+"?charset=utf8", user, passwd)
        riotapi.set_data_store(cassdb)

        riotapi.set_region(r)

        try:
            s = riotapi.get_summoner_by_name(summ)
            if s is not None:
                zone_summoners.append((r, s))
                print("{} from {} appended".format(s.name, r))
        except APIError as error:
            print(error)
            print(error.error_code)

        cassdb.close() # attempt to avoid mysql went away

    if len(zone_summoners) == 0:
        error = "Summoner with that name not found. Try another one."
        return render_template('index.html', error=error)

    patch = riotapi.get_versions()[0]

    return render_template('zone.html',
                        zone_summoners = zone_summoners,
                        summname = summ,
                        patch = patch)
Пример #9
0
def main():
    db = SQLAlchemyDB("sqlite", "", "matches.db", "", "")
    get_matches(get_summoners())
    db.close()