def get_player_standard_stats(self): ''' Get standard stats for a whole season, it doesn't matter if the player has played in one team or more than one team :return: A list of dicctionaries with standard stats ''' if self.params["id"] is not None: args = [self.params["id"], self.params["id_season"]] if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "player.standard.stats.by.id=") else: data = SearchDataFIBA(args, "player.standard.stats.by.id=") else: args = [self.params["id_player_team"]] if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "player.standard.stats.by.id_player_team=") else: data = SearchDataFIBA( args, "player.standard.stats.by.id_player_team=") self.name = self.get_player_name( data.get_result().getData()[0]["id_player"]) self.name_url = self.get_player_name_url( data.get_result().getData()[0]["id_player"]) self.season = self.get_season_name( data.get_result().getData()[0]["id_player"], self.params["id_season"]) return data.get_result().getData()
def get_points_x_player(self, id_team, competition): args = [id_team] if competition == COMPETITIONS.LF1 or competition == COMPETITIONS.LF2: data = SearchData(args, "player.total.points=") else: data = SearchDataFIBA(args, "player.total.points=") return data.get_result().getData()
def get_abrev(self, id_team, competition): args = [id_team] if competition == COMPETITIONS.LF1 or competition.LF2: data = SearchData(args, "team.abrev=") else: data = SearchDataFIBA(args, "team.abrev=") return data.get_result().getData()[0]["abrev"]
def test_players_from_team(self): params = { 'report': 5, "destiny": 770, "type": "player_acc", 'id': 2063, 'id_player_team': None, 'date': '19/08/2020', 'id_season': 45, 'competition': 'FEB-LF1' } args = [params["destiny"]] if params["competition"] == COMPETITIONS.LF1 or params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "team.players=") else: data = SearchDataFIBA(args, "team.players=") players = data.get_result().getData() for player in players: args = { "type": "player_acc", "destiny": params["destiny"], "competition": params["competition"], "id": None, "id_player_team": player["id"], "id_season": params["id_season"], "date": params["date"] } data = DataPlayerAccumulated(args) pdf = PDFPlayerAccumulated(args, data)
def searchGamesFromGameDay(params): args = [params["id_jornada"]] if params["competition"] == COMPETITIONS.LF1 or params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "post.game.by.id.jornada=") else: data = SearchDataFIBA(args, "post.game.by.id.jornada=") return data.get_result().getData()
def get_shots_from_season(competition, id_season): args = [id_season] if competition == COMPETITIONS.LF1: data = SearchData(args, "feb.season.shots=") else: if competition == COMPETITIONS.EUROLEAGUE or competition == COMPETITIONS.EUROCUP: data = SearchDataFIBA(args, "fiba.season.shots=") return pd.DataFrame(data.get_result().getData())
def searchGamePlayed(params): args = [params["id_game"]] if params["competition"] == COMPETITIONS.LF1 or params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "post.game.by.id=") else: data = SearchDataFIBA(args, "post.game.by.id=") return data.get_result().getData()
def get_opp_shots_from_month(self, id_team_club, competition, month, year): args = [id_team_club, id_team_club, id_team_club, year, month] if competition == COMPETITIONS.LF1 or competition == COMPETITIONS.LF2: data = SearchData(args, "opp.shots.by.month=") else: data = SearchDataFIBA(args, "opp.shots.by.month=") self.df = pd.DataFrame(data.get_result().getData()) #We have a new dataframe, so we have to add "position" column and set positions self.add_column("position") self.set_positions()
def get_shots_from_team(id_team_club, competition): '''Returns a dataFrame with the shots made it for all the players of a team in a whole season''' args = [id_team_club] data = None if competition == COMPETITIONS.LF1 or competition == COMPETITIONS.LF2: data = SearchData(args, "feb.team.shots=") else: if competition == COMPETITIONS.EUROLEAGUE or competition == COMPETITIONS.EUROCUP: data = SearchDataFIBA(args, "fiba.team.shots=") return pd.DataFrame(data.get_result().getData())
def get_opp_advanced_stats(self, id_team): ''' This method returns a dictionary with advanced stats from opponents of a team :param id_team: Team searched :return: Returns a dictionary ''' args = [id_team] if self.params["competition"] == COMPETITIONS.LF1 or self.params["competition"] == COMPETITIONS.LF2: data = SearchData(args, "opp.advanced.stats=") else: data = SearchDataFIBA(args, "opp.advanced.stats=") return data.get_result().getData()[0]
def get_team_shots(self, id_team): ''' Devuelve un DataFrame del total de los tiros lanzados por un equipo :param id_team: Identificador del equipo sobre el que queremos obtener la informacion :return: DaraFrame ''' args = [id_team] if self.competition == COMPETITIONS.LF1 or self.competition == COMPETITIONS.LF2: data = SearchData(args, "team.shots=") else: data = SearchDataFIBA(args, "team.shots=") return pd.DataFrame(data.get_result().getData())
def get_list_games(self, id_team): ''' This method returns a DataFrame with the list of games played by a team in a whole season :param id_team: id of the team :return: DataFrame ''' args = [id_team, id_team, id_team, id_team] if self.params["competition"] == COMPETITIONS.LF1 or self.params["competition"] == COMPETITIONS.LF2: data = SearchData(args, "team.list.games=") else: data = SearchDataFIBA(args, "team.list.games=") return pd.DataFrame(data.get_result().getData())
def get_team_standard_stats(self, id_team): ''' This method returns a dictionary with standard stats from a team :param id_team: Team searched :return: Returns a dictionary ''' args = [id_team] if self.params["competition"] == COMPETITIONS.LF1 or self.params["competition"] == COMPETITIONS.LF2: data = SearchData(args, "team.standard.stats=") else: data = SearchDataFIBA(args, "team.standard.stats=") return data.get_result().getData()[0]
def get_players(self, id_team): ''' Devuelve una lista de diccionarios con los datos de las jugadoras del equipo :param id_team: Identificador del equipo por el que buscamos las jugadoras :return: list ''' args = [id_team] if self.params["competition"] == COMPETITIONS.LF1 or self.params["competition"] == COMPETITIONS.LF2: data = SearchData(args, "team.players=") else: data = SearchDataFIBA(args, "team.players=") return data.get_result().getData()
def get_abrev(self, id_team, competition): ''' Devuelve la abreviatra del equipo :param id_team: Identificador del equipo del que queremos la abreviatura :param competition: Identificador de la competiciĆ³n en la que juega :return: Devuelte un string ''' args = [id_team] if competition == COMPETITIONS.LF1 or competition.LF2: data = SearchData(args, "team.abrev=") else: data = SearchDataFIBA(args, "team.abrev=") return data.get_result().getData()[0]["abrev"]
def searchNextGameDay(params): ''' :param params: competition: id of competition :return: list of dictionaries with the data of all games of next gameday ''' if params["competition"] == COMPETITIONS.LF1: data = SearchData(None, "feb.lf1.next.gameday=") if params["competition"] == COMPETITIONS.LF2: data = SearchData(None, "feb.lf2.next.gameday=") if params["competition"] == COMPETITIONS.EUROLEAGUE: data = SearchDataFIBA(None, "fiba.euroleague.next.gameday=") if params["competition"] == COMPETITIONS.EUROCUP: data = SearchDataFIBA(None, "fiba.eurocup.next.gameday=") return data.get_result().getData()
def get_season_name(self, id, id_season): ''' Method which returns the name of the season where have been played by a player :param id: id of the player (tbl003_player) :return: A string with the name of the season ''' if id is not None: args = [id, id_season] if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "season.name=") else: data = SearchDataFIBA(args, "season.name=") return data.get_result().getData()[0]["description"] else: return None
def get_player_name_url(self, id): ''' Method which returns the name of a player through it's id :param id: id of the player (tbl003_player) :return: A string with the name of the player ''' if id is not None: args = [id] if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "player.name=") else: data = SearchDataFIBA(args, "player.name=") return data.get_result().getData()[0]["name_url"] else: return None
def searchNextGame(params): ''' Return a list of dictionaries with the data of next game :param params: list with values like :return: ''' args = [params["team"], params["team"]] if params["competition"] == COMPETITIONS.LF1: data = SearchData(args, "feb.lf1.next.game=") if params["competition"] == COMPETITIONS.LF2: data = SearchData(args, "feb.lf2.next.game=") if params["competition"] == COMPETITIONS.EUROLEAGUE: data = SearchDataFIBA(args, "fiba.euroleague.next.game=") if params["competition"] == COMPETITIONS.EUROCUP: data = SearchDataFIBA(args, "fiba.eurocup.next.game=") return data.get_result().getData()
def get_shots_from_month(self, id_team_club, competition, month, year): ''' Returns a DataFrame with the shots of a team in a month played :param id_team_club: :param competition: :param month: :param year: :return: ''' args = [id_team_club, year, month] data = None if competition == COMPETITIONS.LF1 or competition == COMPETITIONS.LF2: data = SearchData(args, "team.shots.by.month=") else: data = SearchDataFIBA(args, "team.shots.by.month=") self.df = pd.DataFrame(data.get_result().getData()) #We have a new dataframe, so we have to add "position" column and set positions self.add_column("position") self.set_positions()
def create_players_pdf(self, params): args = [self.params["destiny"]] if params["competition"] == COMPETITIONS.LF1 or params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "team.players=") else: data = SearchDataFIBA(args, "team.players=") players = data.get_result().getData() for player in players: args = { "type": "player_acc", "destiny": params["destiny"], "competition": params["competition"], "id": None, "id_player_team": player["id"], "id_season": params["id_season"], "date": params["date"] } data = DataPlayerAccumulated(args) pdf = PDFPlayerAccumulated(args, data)
def send_mail(self, subject, txt, fileName): args = self.params["destiny"] if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "subscriptors.emails=") else: data = SearchDataFIBA(args, "subscriptors.emails=") emails = data.get_result().getData() for item in emails: print(f"Enviamos informe a la cuenta: {item['email']}") params = { "from": "*****@*****.**", "to": item["email"], "subject": subject, "message": txt, "fileName": fileName, "routeFile": f"output/reports/{self.params['destiny']}/" } mail = Mail(params) message = mail.create_message() service = mail.get_service() mail.send_message(service, "*****@*****.**", message)
def get_shots(self): ''' Get all shots made it by a player. It doesn't matter if the player played in one or more teams :return: A DataFrame ''' if self.params["id"] is not None: args = [self.params["id"], self.params["id_season"]] if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: data = SearchData(args, "feb.player.shots.season=") else: data = SearchDataFIBA(args, "fiba.player.accumulated=") else: if self.params["competition"] == COMPETITIONS.LF1 or self.params[ "competition"] == COMPETITIONS.LF2: args = [self.params["id_player_team"]] data = SearchData(args, "feb.player.shots=") else: args = [ self.params["id_player_team"], self.params["id_season"] ] data = SearchDataFIBA(args, "fiba.player.accumulated=") return pd.DataFrame(data.get_result().getData())