def getTeamInfo(number): data = read_tba.get("team/frc" + str(number) + "/simple") name = data["nickname"] state = data["state_prov"] country = data["country"] years = len(read_tba.get("team/frc" + str(number) + "/years_participated")) try: district = read_tba.get("team/frc" + str(number) + "/districts")[-1]["abbreviation"] except Exception: district = "None" if (state in USA): state = USA[state] elif (state in Canada): state = Canada[state] elif (country != "USA" and country != "Canada"): state = "All" if (district in districts): district = districts[district] return [name, country, state, district, years]
def getMatchesEvent(year, event): matches = [] event_time = getEventTime(event) for match in read_tba.get("event/" + str(event) + "/matches/simple"): # correctly orders matches pre 2016 match["actual_time"] = getMatchTime(match, event_time) red_teams = len(match["alliances"]["red"]["team_keys"]) blue_teams = len(match["alliances"]["blue"]["team_keys"]) if (year > 2004 and red_teams == 3 and blue_teams == 3): matches.append(Match(match)) elif (year <= 2004 and red_teams >= 2 and blue_teams >= 2): matches.append(Match(match)) matches.sort() return matches
def getEvents(year): events = [] for event in read_tba.get("events/" + str(year) + "/simple"): if (event["event_type"] <= 10): events.append(event["key"]) return events
def getEventTime(event): # for pre 2016 events date = read_tba.get("event/" + str(event) + "/simple")["start_date"] return int(datetime.datetime.strptime(date, "%Y-%m-%d").timestamp())
def getTeams(event): return read_tba.get("event/" + str(event) + "/teams/keys")