def Get_Tournament_Games(_tournaments, _tournament_name): games = [] for i in _tournaments: if i.name == _tournament_name: games = lp.get_games(i.overviewPage) break return games
def test_get_details(tournament_name): games = leaguepedia_parser.get_games(tournament_name) # First, test without pageId leaguepedia_parser.get_game_details(games[0]) # Then test with pageId game = leaguepedia_parser.get_game_details(games[0], True) assert "picksBans" in game for team in "BLUE", "RED": assert len(game["teams"][team]["players"]) == 5 for player in game["teams"][team]["players"]: assert "irlName" in player["uniqueIdentifiers"]["leaguepedia"] assert "birthday" in player["uniqueIdentifiers"]["leaguepedia"] assert "pageId" in player["uniqueIdentifiers"]["leaguepedia"]
import leaguepedia_parser as lp import pprint # Setup: pp = pprint.PrettyPrinter(indent=4) tournaments = lp.get_tournaments("North America", year=2020) tourney = [] flyBans = [] flyBans_versus = [] gameData = [] for x in tournaments: tourney.append(x["overviewPage"]) tourneyIDX = tourney.index("LCS/2020 Season/Summer Playoffs") games = lp.get_games(tourney[tourneyIDX]) # # THEORY / UNDERSTANDING THE OUTPUT #n = 0 # different numbers correspond to different games # for any game x, list(x.values()) will present an array with information for the game # As of now, index 8 contains a dictionary with blue and red side draft #y = list(games[n].values())[8] #n2 = 0 # Set to 1 for blue side, and set to 2 for red side #z = list(y.values())[n2] # if you do [ z.get('name') == "FlyQuest": ] # obtain picks and bans for this side # From here, we can do "z.get("bansNames")" to obtain bans for one side of a game. # :) # # Bans for all games of one team (teamChoice) in a given tournament
def get_tournament_games(tournament): # Gets all games for a tournament. Get the name from get_tournaments() return leaguepedia_parser.get_games(tournament)
#!/usr/bin/env python import sys import leaguepedia_parser as lp import json import requests #FORMAT ARGUMENT: "LEC/2021 Season/Spring Season" argument = sys.argv[1] + "/" + sys.argv[2] + " Season/" + sys.argv[ 3] + " Season" games = lp.get_games(argument) outfile = open('../py/datosCompletos.json', "w") for i in games: game = lp.get_game_details(i) json.dump(game, outfile) outfile.write('\n')
tournament_name = sys.argv[1].split(",")[1].strip() tournament_games = [] tournaments = lp.get_tournaments(region, 2021) gf.Check_Tournaments(tournaments) tournament_games = gf.Get_Tournament_Games(tournaments, tournament_name) #print(region) #print(tournament_name) #print(champion_name) #print(lp.get_regions()) #tournaments = lp.get_tournaments(region, 2021) #print(tournaments) gf.Check_Tournaments(tournaments) for i in tournaments: if i.name == tournament_name: tournament_games = lp.get_games(i.overviewPage) #print(tournament_games) games = [] for i in tqdm(range(len(tournament_games)), desc="In Progress"): #some tournament sometimes do a blind pick first match in a series and therefore there is no pick ban for this, however every subsequent games does there fore we need to skip this games #but also tell the user why we skipped #print("--") game = lp.get_game_details(tournament_games[i]) #print("PICK AND BANS: " + str(game.picksBans)) #print("GAME WINNER: " + str(game.winner)) #print(game.teams) pb_order = game.picksBans side_win = game.winner teams = game.teams pb_json = gf.Generate_Pick_Ban_Data(pb_order, side_win, teams) #if lp.get_game_details(tournament_games[i].picksBans) is not None:
def test_games(tournament_name): games = leaguepedia_parser.get_games(tournament_name) assert len(games) > 0