def print_leagues(summoner_name: str, region: str): summoner = Summoner(name=summoner_name, region=region) print("Name:", summoner.name) print("ID:", summoner.id) # positions = cass.get_league_positions(summoner, region=region) positions = summoner.league_positions if positions.fives.promos is not None: # If the summoner is in their promos, print some info print("Promos progress:", positions.fives.promos.progress) print("Promos wins", positions.fives.promos.wins) print("Promos losses:", positions.fives.promos.losses) print("Games not yet played in promos:", positions.fives.promos.not_played) print("Number of wins required to win promos:", positions.fives.promos.wins_required) else: print("The summoner is not in their promos.") print("Name of leagues this summoner is in:") for league in positions: print(league.name) print() leagues = summoner.leagues print(f"Listing all summoners in this league:") for entry in leagues.fives[Position.utility]: print(entry.summoner.name, entry.league_points, entry.tier, entry.division, entry.position) print() print("Master's League name:") masters = cass.get_master_league(queue=Queue.ranked_solo_fives, region=region) print(masters.name)
def print_leagues(summoner_name: str, region: str): summoner = Summoner(name=summoner_name, region=region) print("Name:", summoner.name) print("ID:", summoner.id) # entries = cass.get_league_entries(summoner, region=region) entries = summoner.league_entries if entries.fives.promos is not None: # If the summoner is in their promos, print some info print("Promos progress:", entries.fives.promos.progress) print("Promos wins", entries.fives.promos.wins) print("Promos losses:", entries.fives.promos.losses) print("Games not yet played in promos:", entries.fives.promos.not_played) print("Number of wins required to win promos:", entries.fives.promos.wins_required) else: print("The summoner is not in their promos.") print("Name of leagues this summoner is in:") for entry in entries: print(entry.league.name) print() print(f"Listing all summoners in this league:") for position, entry in enumerate(entries.fives.league.entries): print(entry.summoner.name, entry.league_points, entry.tier, entry.division, position) print() print("Master's League name:") masters = cass.get_master_league(queue=Queue.ranked_solo_fives, region=region) print(masters.name)
def save_gosu_player(region: str): lol_gosu_names = [] try: challenger_league = cass.get_challenger_league(queue=queueType, region=region) challenger_entries = challenger_league.entries for challenger in challenger_entries: lol_gosu_names.append(challenger.summoner.account_id) grandmaster_league = cass.get_grandmaster_league(queue=queueType, region=region) grandmaster_entries = grandmaster_league.entries for grandmaster in grandmaster_entries: lol_gosu_names.append(grandmaster.summoner.account_id) master_league = cass.get_master_league(queue=queueType, region=region) master_entries = master_league.entries for master in master_entries: lol_gosu_names.append(master.summoner.account_id) except: print("Server error raise. Wait for 1 second.") time.sleep(1) pass return lol_gosu_names
def test_leagues(): summoner_name = "Spartan324" region = "NA" summoner = Summoner(name=summoner_name, region=region) "Name:", summoner.name "ID:", summoner.id # positions = cass.get_league_positions(summoner, region=region) positions = summoner.league_positions if positions.fives.promos is not None: # If the summoner is in their promos, print some info "Promos progress:", positions.fives.promos.progress "Promos wins", positions.fives.promos.wins "Promos losses:", positions.fives.promos.losses "Games not yet played in promos:", positions.fives.promos.not_played "Number of wins required to win promos:", positions.fives.promos.wins_required else: "The summoner is not in their promos." "Name and id of leagues this summoner is in:" for league in positions: league.name league.league_id leagues = cass.get_leagues(summoner) leagues = summoner.leagues "Name of leagues this summoner is in (called from a different endpoint):" for league in leagues: #league.name league.id f"Listing all summoners in {leagues.fives.id}" for entry in leagues.fives: entry.summoner.name, entry.league_points, leagues.fives.tier, entry.division "Challenger League name and id:" challenger = cass.get_challenger_league(queue=Queue.ranked_solo_fives, region=region) # challenger.name challenger.id "Grandmaster League name and id:" grandmaster = cass.get_grandmaster_league(queue=Queue.ranked_solo_fives, region=region) # grandmaster.name grandmaster.id "Master League name and id:" master = cass.get_master_league(queue=Queue.ranked_solo_fives, region=region) # master.name master.id
def test_leagues(): summoner_name = "Kalturi" region = "NA" summoner = Summoner(name=summoner_name, region=region) "Name:", summoner.name "ID:", summoner.id # entries = cass.get_league_entries(summoner, region=region) entries = summoner.league_entries if entries.fives.promos is not None: # If the summoner is in their promos, print some info "Promos progress:", entries.fives.promos.progress "Promos wins", entries.fives.promos.wins "Promos losses:", entries.fives.promos.losses "Games not yet played in promos:", entries.fives.promos.not_played "Number of wins required to win promos:", entries.fives.promos.wins_required else: "The summoner is not in their promos." "Name and id of fives leagues this summoner is in:" for entry in entries.fives: entry.league.name entry.league.id f"Listing all summoners in {entry.league.id}" for other_entry in entry.league.entries: other_entry.summoner.name, other_entry.league_points, entry.league.tier, other_entry.division "Challenger League name and id:" challenger = cass.get_challenger_league(queue=Queue.ranked_solo_fives, region=region) # challenger.name challenger.id "Grandmaster League name and id:" grandmaster = cass.get_grandmaster_league(queue=Queue.ranked_solo_fives, region=region) # grandmaster.name grandmaster.id "Master League name and id:" master = cass.get_master_league(queue=Queue.ranked_solo_fives, region=region) # master.name master.id
def update_matches(player, region, min_time=7200, max_matches=100): try: match_history = cass.MatchHistory( summoner=cass.get_summoner(name=player), queues={cass.Queue.ranked_solo_fives})[:max_matches] return match_history except: return [] x = 0 players_list = [ cass.get_challenger_league(queue=cass.Queue.ranked_solo_fives), cass.get_master_league(queue=cass.Queue.ranked_solo_fives) ] for players in players_list: cps = [p.summoner.name for p in players] n = -1 matches = get_matches(region) while n < len(cps) - 1: n += 1 p = cps[n] print("summoner:", p) now_time = int(datetime.datetime.now().timestamp()) if now_time - get_last_game(p) < MIN_TIME: print("too soon:", now_time - get_last_game(p), p) continue match_history = update_matches(p, region) try:
def index(request): cass.set_riot_api_key("RGAPI-daa909e6-146f-4c9d-a03a-2ff08bac37be") cass.set_default_region("NA") na_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5') # euw_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='EUW') # eune_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='EUNE') # kr_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='KR') # jp_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='JP') # br_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='BR') # ru_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='RU') # lan_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='LAN') # las_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='LAS') # oce_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='OCE') # tr_challenger_players = cass.get_challenger_league(queue='RANKED_SOLO_5x5', region='TR') for p in na_challenger_players: obj, created = NA_Pros.objects.update_or_create( summoner_ID=p.summoner.id, defaults={'summoner_name': p.summoner.name}) if created: print('Created entry: ' + obj.summoner_name) else: print('Found entry: ' + obj.summoner_name) # for p in euw_challenger_players: # obj, created = EUW_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in eune_challenger_players: # obj, created = EUNE_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in kr_challenger_players: # obj, created = KR_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in jp_challenger_players: # obj, created = JP_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in br_challenger_players: # obj, created = BR_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in ru_challenger_players: # obj, created = RU_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in lan_challenger_players: # obj, created = LAN_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in las_challenger_players: # obj, created = LAS_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in oce_challenger_players: # obj, created = OCE_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in tr_challenger_players: # obj, created = TR_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) na_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5') # euw_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='EUW') # eune_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='EUNE') # kr_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='KR') # jp_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='JP') # br_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='BR') # ru_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='RU') # lan_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='LAN') # las_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='LAS') # oce_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='OCE') # tr_master_players = cass.get_master_league(queue='RANKED_SOLO_5x5', region='TR') for p in na_master_players: obj, created = NA_Pros.objects.update_or_create( summoner_ID=p.summoner.id, defaults={'summoner_name': p.summoner.name}) if created: print('Created entry: ' + obj.summoner_name) else: print('Found entry: ' + obj.summoner_name) # for p in euw_master_players: # obj, created = EUW_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in eune_master_players: # obj, created = EUNE_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in kr_master_players: # obj, created = KR_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in jp_master_players: # obj, created = JP_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in br_master_players: # obj, created = BR_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in ru_master_players: # obj, created = RU_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in lan_master_players: # obj, created = LAN_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in las_master_players: # obj, created = LAS_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in oce_master_players: # obj, created = OCE_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # for p in tr_master_players: # obj, created = TR_Pros.objects.update_or_create(summoner_ID=p.summoner.id, defaults={'summoner_name':p.summoner.name}) # if created: # print('Created entry: ' + obj.summoner_name) # else: # print('Found entry: ' + obj.summoner_name) # return render(request, 'getpros/header.html')