def partial_teamsidestats(request): data = simplejson.loads(request.body) code = data.get("stat") common_param = {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID} # if the said statistics can be retreived from the get_standings method (TF_STANDINGS) if code in ["score", "conceded", "average"]: a = prune_dicts(["teamId", code], get_standings()) elif code == "pass": a = service_request("GetTeamPass", common_param) elif code in ["shot", "shoton"]: a = service_request("GetTeamShot", common_param) ix = 1 if code=="shot" else 2 a = prune_lists([0,ix], a) elif code == "distance": a = service_request("GetTeamRun", common_param) a = prune_lists([0,2], a) elif code in ["foul", "yellow", "red"]: ix = {"foul": 1, "yellow": 3, "red": 4}.get(code) a = service_request("GetTeamFoul", common_param) a = prune_lists([0, ix], a) else: return HttpResponse() # return HttpResponse(simplejson.dumps(a), mimetype="application/json") return render_to_response('_sc_team_sidebar.html', {"slist": a})
def partial_teamsidestats(request): data = simplejson.loads(request.body) code = data.get("stat") common_param = {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID} # if the said statistics can be retreived from the get_standings method (TF_STANDINGS) if code in ["score", "conceded", "average"]: a = prune_dicts(["teamId", code], get_standings()) elif code == "pass": a = service_request("GetTeamPass", common_param) elif code in ["shot", "shoton"]: a = service_request("GetTeamShot", common_param) ix = 1 if code == "shot" else 2 a = prune_lists([0, ix], a) elif code == "distance": a = service_request("GetTeamRun", common_param) a = prune_lists([0, 2], a) elif code in ["foul", "yellow", "red"]: ix = {"foul": 1, "yellow": 3, "red": 4}.get(code) a = service_request("GetTeamFoul", common_param) a = prune_lists([0, ix], a) else: return HttpResponse() # return HttpResponse(simplejson.dumps(a), mimetype="application/json") return render_to_response('_sc_team_sidebar.html', {"slist": a})
def home(request,weekId): weeks = service_request("GetWeeks", {"leagueId":LEAGUE_ID,"seasonId":SEASON_ID}) weekNumber, lastPlayed = weeks[0][0], weeks[0][1] weekDict = range(1, weekNumber+1) top_passers = get_top5("pass", weekId) map(lambda x: x.append("%%%s"%int(float(x[4])*100/float(x[3]))), top_passers) best_eleven = get_besteleven(weekId) print best_eleven return render_to_response('sc_home.html', {'fixture':get_fixture(), 'weekList':weekDict, 'leagueId':LEAGUE_ID, 'seasonId':SEASON_ID, 'weekSelected': int(weekId), 'lastPlayedWeek':int(lastPlayed), 'standing_list':get_standings_by_week(int(weekId)), 'best_eleven_list':None, 'top_passers': top_passers, 'top_scorers': get_top5("goal", weekId), 'top_runners': get_top5("distance", weekId), 'quad_ace': get_quadace(weekId), 'best_eleven': best_eleven})
def get_besteleven(week): """ Get Best Eleven of a given week :type week: int """ bestlist = service_request("GetBestElevenPreset", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "week": week }) bestDict = [] i = 1 for player in bestlist: bestDict.append({ "playerId": player[0], "playerName": player[1], "playPosition": player[3], "teamId": player[4], "teamName": player[5], "jerseyNumber": i }) i = i + 1 return bestDict
def get_top5(item, week): """ Get Top 5 players in a given item, wrapper function for GetBestX type functions :param item: the item, one of "pass", "distance", "goal" :type item: str """ method = { "pass": ("GetBestPassers", [0, 1, 2, 5, 6]), "goal": ("GetBestScorers", [0, 1, 2, 5, 6, 7]), "distance": ("GetBestRunners", [0, 1, 2, 5, 11, 12]) }.get(item) data = { "league_id": LEAGUE_ID, "season_id": SEASON_ID, "count": 5, "weekList": [str(week)] } if not method: raise AttributeError( "You must provide one of 'pass', 'distance' or 'goal' as argument") return prune_lists_nosort(method[1], service_request(method[0], data))
def home(request, weekId): weeks = service_request("GetWeeks", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) weekNumber, lastPlayed = weeks[0][0], weeks[0][1] weekDict = range(1, weekNumber + 1) top_passers = get_top5("pass", weekId) map(lambda x: x.append("%%%s" % int(float(x[4]) * 100 / float(x[3]))), top_passers) best_eleven = get_besteleven(weekId) print best_eleven return render_to_response( 'sc_home.html', { 'fixture': get_fixture(), 'weekList': weekDict, 'leagueId': LEAGUE_ID, 'seasonId': SEASON_ID, 'weekSelected': int(weekId), 'lastPlayedWeek': int(lastPlayed), 'standing_list': get_standings_by_week(int(weekId)), 'best_eleven_list': None, 'top_passers': top_passers, 'top_scorers': get_top5("goal", weekId), 'top_runners': get_top5("distance", weekId), 'quad_ace': get_quadace(weekId), 'best_eleven': best_eleven })
def get_standings(): standingDict = [] current_week = get_week_details()[0][1] datalist = service_request("GetStandings", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "type": 0 }) if len(datalist) == 0: return [] current_week_tuples = [x for x in datalist if x[0] == current_week] for item in current_week_tuples: standingDict.append({ 'teamId': int(item[1]), 'teamName': item[2], 'played': int(item[3]), 'win': int(item[4]), 'draw': int(item[5]), 'lose': int(item[6]), 'score': int(item[7]), 'conceded': int(item[8]), 'average': int(item[9]), 'points': int(item[10]), 'change': int(item[11]) }) return standingDict
def get_fixture(): weeklist = service_request("GetFixture", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) fixtureDict = [] if len(weeklist) == 0: return [] for week_id in weeklist: week = weeklist[week_id] matches = [] for matchId in week: if matchId == "weekStatus": status = week[matchId] else: matches.append({'matchId':matchId, 'matchStatus':week[matchId][0], 'homeTeam':week[matchId][1], 'homeTeamCond':week[matchId][2], 'homeTeamInt':week[matchId][3], 'awayTeam':week[matchId][4], 'awayTeamCond':week[matchId][5], 'awayTeamInt':week[matchId][6], 'homeTeamId':int(week[matchId][7]), 'awayTeamId':int(week[matchId][8]), 'homeScore':week[matchId][9], 'awayScore':week[matchId][10], 'date':week[matchId][11], 'liveTime':week[matchId][12], 'referee':week[matchId][13], 'stadium':week[matchId][14]}) fixtureDict.append({'weekId':int(week_id),'status':status,'matches':matches}) return fixtureDict
def get_team_card(tid): """ :param tid: team id """ list = service_request("GetTeamCard", { "teamId": tid, "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) turkify_stat = lambda x: { "CrossSuccess": (u"İsabetli Orta", 8), "CrossTotal": (u"Toplam Orta", 7), "Faul": (u"Yapılan Faul", 9), "Goal": (u"Gol", 1), "GoalConceded": (u"Yenilen Gol", 2), "PassSuccess": (u"İsabetli Pas", 6), "PassTotal": (u"Toplam Pas", 5), "RedCard": (u"Kırmızı Kart", 11), "ShotSuccess": (u"İsabetli Şut", 4), "ShotTotal": (u"Toplam Şut", 3), "YellowCard": (u"Sarı Kart", 10) }.get(x) res = [[ turkify_stat(x[0])[0], turkify_stat(x[0])[1], int(x[1]), int(x[2]) ] for x in list] res = sorted(res, key=lambda x: x[1]) return res
def get_team_form(teamId): data = { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "teamId": teamId, "type": 0, "weekId": 40 } teamlist = service_request("GetTeamForm", data) getwin = lambda x, team: 1 if (int(x[2]) > int(x[3]) and int(x[4]) == team) or (int(x[2]) < int(x[3]) and int(x[5]) == team) \ else (0 if int(x[2]) == int(x[3]) else 2) # TODO: Verinin cogunu kullanmiyoruz neden template e pasliyoruz? getlist = lambda x, team: [{ 'matchId': match[0], 'matchName': match[1], 'homeScore': match[2], 'awayScore': match[3], 'homeTeamId': match[4], 'awayTeamId': match[5], 'homeTeam': match[6], 'awayTeam': match[7], 'weekId': match[8], 'win': getwin(match, team) } for match in x] return getlist(teamlist, teamId)
def get_team_card(tid): """ :param tid: team id """ list = service_request("GetTeamCard", {"teamId": tid, "leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) turkify_stat = lambda x: {"CrossSuccess": (u"İsabetli Orta", 8), "CrossTotal": (u"Toplam Orta", 7), "Faul": (u"Yapılan Faul", 9), "Goal": (u"Gol", 1), "GoalConceded": (u"Yenilen Gol", 2), "PassSuccess": (u"İsabetli Pas", 6), "PassTotal": (u"Toplam Pas", 5), "RedCard": (u"Kırmızı Kart", 11), "ShotSuccess": (u"İsabetli Şut", 4), "ShotTotal": (u"Toplam Şut", 3), "YellowCard": (u"Sarı Kart", 10)}.get(x) res = [[turkify_stat(x[0])[0], turkify_stat(x[0])[1], int(x[1]), int(x[2])] for x in list] res = sorted(res, key=lambda x: x[1]) return res
def get_standings_by_week(weekid): standingDict = [] datalist = service_request("GetStandings", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "type": 0 }) if len(datalist) == 0: return [] for item in datalist: if int(item[0]) == int(weekid): standingDict.append({ 'teamId': int(item[1]), 'teamName': item[2], 'played': int(item[3]), 'win': int(item[4]), 'draw': int(item[5]), 'lose': int(item[6]), 'score': int(item[7]), 'conceded': int(item[8]), 'average': int(item[9]), 'points': int(item[10]), 'change': int(item[11]) }) return standingDict
def get_team_players(teamid): datalist = service_request("GetTeamPlayers", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "teamId": teamid }) playerDict = [] if len(datalist) == 0: return [] coal = lambda x: x if x is not None else 0 for x in datalist: playerDict.append({ 'playerId': coal(x[0]), 'playerName': coal(x[1]), 'jerseyNumber': coal(x[2]), 'position': coal(x[3]), 'match': int(coal(x[4])), 'minutes': int(coal(x[5])), 'goals': int(coal(x[6])), 'assists': int(coal(x[7])), 'yellowCards': int(coal(x[8])), 'redCards': int(coal(x[9])) }) return playerDict
def get_top5(item, week): """ Get Top 5 players in a given item, wrapper function for GetBestX type functions :param item: the item, one of "pass", "distance", "goal" :type item: str """ method = { "pass": ("GetBestPassers", [0,1,2,5,6]), "goal": ("GetBestScorers", [0,1,2,5,6,7]), "distance": ("GetBestRunners", [0,1,2,5,11,12]) }.get(item) data = { "league_id": LEAGUE_ID, "season_id": SEASON_ID, "count": 5, "weekList": [str(week)] } if not method: raise AttributeError("You must provide one of 'pass', 'distance' or 'goal' as argument") return prune_lists_nosort(method[1], service_request(method[0], data))
def get_player_last_goals(pid): """ :param pid: player id """ return service_request("GetPlayerGoals", {"playerId": pid, "count": 5, "leagueId": LEAGUE_ID, "seasonId": SEASON_ID})
def get_team_past_standings(tid): """ :param tid: team id :param weekid: week id """ return service_request("GetTeamPastPositions", {"teamId": tid, "leagueId": LEAGUE_ID, "seasonId": SEASON_ID})
def get_teams(): datalist = service_request("GetTeams", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) teamDict = [] if len(datalist) == 0: return [] for x in datalist: teamDict.append({'teamId':x[0],'teamName':x[1]}) return teamDict
def get_player_last_goals(pid): """ :param pid: player id """ return service_request("GetPlayerGoals", { "playerId": pid, "count": 5, "leagueId": LEAGUE_ID, "seasonId": SEASON_ID })
def get_team_past_standings(tid): """ :param tid: team id :param weekid: week id """ return service_request("GetTeamPastPositions", { "teamId": tid, "leagueId": LEAGUE_ID, "seasonId": SEASON_ID })
def get_best_scorers(weekid, count): week = 0 weeks = [] while week < weekid: weeks.append(week) bestList = service_request( "GetBestScorers", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "weekList": weeks, "count": count })
def get_teams(): datalist = service_request("GetTeams", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) teamDict = [] if len(datalist) == 0: return [] for x in datalist: teamDict.append({'teamId': x[0], 'teamName': x[1]}) return teamDict
def get_team_shot(): shotList = service_request("GetTeamShot", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) shotDict = [] for shot in shotList: shotDict.append( {shot[0]: { "shotTotal": shot[1], "shotSuccessful": shot[2] }}) return shotDict
def get_besteleven(week): """ Get Best Eleven of a given week :type week: int """ bestlist = service_request("GetBestElevenPreset", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "week": week}) bestDict = [] i = 1 for player in bestlist: bestDict.append({"playerId":player[0],"playerName":player[1],"playPosition":player[3],"teamId":player[4],"teamName":player[5],"jerseyNumber":i}) i = i + 1 return bestDict
def get_team_goal(): goalList = service_request("GetTeamGoal", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) goalDict = [] for goal in goalList: goalDict.append({ goal[0]: { "scored": goal[1], "conceded": goal[2], "penaltyGoal": goal[3] } }) return goalDict
def get_team_foul(): foulList = service_request("GetTeamFoul", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) foulDict = [] for foul in foulList: foulDict.append({ foul[0]: { "foulCommitted": foul[1], "foulSuffered": foul[2], "yellow": foul[3], "red": foul[4] } }) return foulDict
def get_team_pass(): passList = service_request("GetTeamPass", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) passDict = [] for pas in passList: passDict.append({ pas[0]: { "passTotal": pas[1], "passSuccessful": pas[2], "crossTotal": pas[3], "crossSuccessful": pas[3] } }) return passDict
def get_player_details(playerid): datalist = service_request("GetPlayerDetails", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID,"playerId": playerid}) detailDict = [] if len(datalist) == 0: return [] for obj in datalist: detailDict.append({'playerName':obj[0], 'date':obj[1], 'height':obj[2], 'nation':obj[3], 'cap':obj[4], 'goal':obj[5], 'teamId':obj[6], 'teamName':obj[7]}) return detailDict
def get_team_run(): runList = service_request("GetTeamRun", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) runDict = [] for run in runList: runDict.append({ run[0]: { "matches": run[1], "totalDistance": run[2], "averageSpeed": run[3], "HIRDistance": run[4], "sprintDistance": run[5], "HIRNumber": run[6], "sprintNumber": run[7] } }) return runDict
def get_fixture(): weeklist = service_request("GetFixture", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) fixtureDict = [] if len(weeklist) == 0: return [] for week_id in weeklist: week = weeklist[week_id] matches = [] for matchId in week: if matchId == "weekStatus": status = week[matchId] else: matches.append({ 'matchId': matchId, 'matchStatus': week[matchId][0], 'homeTeam': week[matchId][1], 'homeTeamCond': week[matchId][2], 'homeTeamInt': week[matchId][3], 'awayTeam': week[matchId][4], 'awayTeamCond': week[matchId][5], 'awayTeamInt': week[matchId][6], 'homeTeamId': int(week[matchId][7]), 'awayTeamId': int(week[matchId][8]), 'homeScore': week[matchId][9], 'awayScore': week[matchId][10], 'date': week[matchId][11], 'liveTime': week[matchId][12], 'referee': week[matchId][13], 'stadium': week[matchId][14] }) fixtureDict.append({ 'weekId': int(week_id), 'status': status, 'matches': matches }) return fixtureDict
def get_player_stats(playerid): """ Invoke GetPlayerCard in api """ weeks = get_week_details() data = service_request( "GetPlayerCard", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "playerId": playerid, "weekId": weeks[0][1] }) stats = data.get("statistics") if not stats: return [] stat_lookup = lambda x: { "passes": "Toplam Pas", "shotsOnTarget": "İsabetli Şut", "crosses": "Toplam Orta", "foulsSuffered": "Maruz Kalınan Faul", "totalDistance": "Kat Edilen Mesafe", "yellowCard": "Sarı Kart", "corners": "Korner", "redCard": "Kırmızı Kart", "successfulCross": "İsabetli Orta", "penalty": "Penaltı", "assists": "Asist", "goals": "Gol", "shots": "Şut", "foulsCommitted": "Yapılan Faul", "matchesPlayed": "Oynadığı Maç Sayısı", "successfulPass": "******" }.get(x) result = {} for i in stats: result[stat_lookup(i)] = [stats[i][0], stats[i][1]] return result
def get_team_form(teamId): data = {"leagueId":LEAGUE_ID,"seasonId":SEASON_ID,"teamId":teamId,"type":0,"weekId":40} teamlist = service_request("GetTeamForm", data) getwin = lambda x, team: 1 if (int(x[2]) > int(x[3]) and int(x[4]) == team) or (int(x[2]) < int(x[3]) and int(x[5]) == team) \ else (0 if int(x[2]) == int(x[3]) else 2) # TODO: Verinin cogunu kullanmiyoruz neden template e pasliyoruz? getlist = lambda x, team: [{'matchId':match[0], 'matchName':match[1], 'homeScore':match[2], 'awayScore':match[3], 'homeTeamId':match[4], 'awayTeamId':match[5], 'homeTeam':match[6], 'awayTeam':match[7], 'weekId':match[8], 'win':getwin(match, team)} for match in x] return getlist(teamlist, teamId)
def get_team_details(teamid): datalist = service_request("GetTeamDetails", {"teamId": teamid}) detailDict = [] if len(datalist) == 0: return [] obj = datalist[0] detailDict.append( {'teamName':obj[0], 'stadium':obj[1], 'foundation':obj[2], 'president':obj[3], 'capacity':obj[4], 'manager':obj[5], 'website':obj[6], 'leaguechamp':obj[7], 'cupchamp':obj[8]}) return detailDict
def get_quadace(week): """ Get QuadAce of a given week :type week: int """ posn_lookup = lambda x: { 1: "Kaleci", 2: "Defans", 3: "Orta Saha", 4: "Forvet" }.get(x) res = service_request("GetQuadAcePreset", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "week": week}) for i in res: i[2] = posn_lookup(i[2]) return res
def get_team_players(teamid): datalist = service_request("GetTeamPlayers", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "teamId": teamid}) playerDict =[] if len(datalist) == 0: return [] coal = lambda x: x if x is not None else 0 for x in datalist: playerDict.append({'playerId':coal(x[0]), 'playerName':coal(x[1]), 'jerseyNumber':coal(x[2]), 'position':coal(x[3]), 'match':int(coal(x[4])), 'minutes':int(coal(x[5])), 'goals':int(coal(x[6])), 'assists':int(coal(x[7])), 'yellowCards':int(coal(x[8])), 'redCards':int(coal(x[9]))}) return playerDict
def get_standings_by_week(weekid): standingDict = [] datalist = service_request("GetStandings",{"leagueId":LEAGUE_ID,"seasonId":SEASON_ID,"type":0}) if len(datalist) == 0: return [] for item in datalist: if int(item[0]) == int(weekid): standingDict.append({'teamId': int(item[1]), 'teamName': item[2], 'played':int(item[3]), 'win':int(item[4]), 'draw':int(item[5]), 'lose':int(item[6]), 'score':int(item[7]), 'conceded' : int(item[8]), 'average':int(item[9]), 'points':int(item[10]), 'change': int(item[11])}) return standingDict
def get_team_details(teamid): datalist = service_request("GetTeamDetails", {"teamId": teamid}) detailDict = [] if len(datalist) == 0: return [] obj = datalist[0] detailDict.append({ 'teamName': obj[0], 'stadium': obj[1], 'foundation': obj[2], 'president': obj[3], 'capacity': obj[4], 'manager': obj[5], 'website': obj[6], 'leaguechamp': obj[7], 'cupchamp': obj[8] }) return detailDict
def get_player_stats(playerid): """ Invoke GetPlayerCard in api """ weeks = get_week_details() data = service_request("GetPlayerCard", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "playerId": playerid, "weekId": weeks[0][1]}) stats = data.get("statistics") if not stats: return [] stat_lookup = lambda x: {"passes": "Toplam Pas", "shotsOnTarget": "İsabetli Şut", "crosses": "Toplam Orta", "foulsSuffered": "Maruz Kalınan Faul", "totalDistance": "Kat Edilen Mesafe", "yellowCard": "Sarı Kart", "corners": "Korner", "redCard": "Kırmızı Kart", "successfulCross": "İsabetli Orta", "penalty": "Penaltı", "assists": "Asist", "goals": "Gol", "shots": "Şut", "foulsCommitted": "Yapılan Faul", "matchesPlayed": "Oynadığı Maç Sayısı", "successfulPass": "******"}.get(x) result = {} for i in stats: result[stat_lookup(i)] = [stats[i][0], stats[i][1]] return result
def get_standings(): standingDict = [] current_week = get_week_details()[0][1] datalist = service_request("GetStandings",{"leagueId":LEAGUE_ID,"seasonId":SEASON_ID,"type":0}) if len(datalist) == 0: return [] current_week_tuples = [x for x in datalist if x[0] == current_week] for item in current_week_tuples: standingDict.append({'teamId': int(item[1]), 'teamName': item[2], 'played':int(item[3]), 'win':int(item[4]), 'draw':int(item[5]), 'lose':int(item[6]), 'score':int(item[7]), 'conceded' : int(item[8]), 'average':int(item[9]), 'points':int(item[10]), 'change': int(item[11])}) return standingDict
def get_quadace(week): """ Get QuadAce of a given week :type week: int """ posn_lookup = lambda x: { 1: "Kaleci", 2: "Defans", 3: "Orta Saha", 4: "Forvet" }.get(x) res = service_request("GetQuadAcePreset", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "week": week }) for i in res: i[2] = posn_lookup(i[2]) return res
def get_player_details(playerid): datalist = service_request("GetPlayerDetails", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID, "playerId": playerid }) detailDict = [] if len(datalist) == 0: return [] for obj in datalist: detailDict.append({ 'playerName': obj[0], 'date': obj[1], 'height': obj[2], 'nation': obj[3], 'cap': obj[4], 'goal': obj[5], 'teamId': obj[6], 'teamName': obj[7] }) return detailDict
def get_week_details(): data = service_request("GetWeeks", {"leagueId":LEAGUE_ID,"seasonId":SEASON_ID}) return data
def get_team_goal(): goalList = service_request("GetTeamGoal", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) goalDict = [] for goal in goalList: goalDict.append({goal[0]:{"scored":goal[1],"conceded":goal[2],"penaltyGoal":goal[3]}}) return goalDict
def get_team_shot(): shotList = service_request("GetTeamShot", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) shotDict = [] for shot in shotList: shotDict.append({shot[0]:{"shotTotal":shot[1],"shotSuccessful":shot[2]}}) return shotDict
def get_week_details(): data = service_request("GetWeeks", { "leagueId": LEAGUE_ID, "seasonId": SEASON_ID }) return data
def get_team_run(): runList = service_request("GetTeamRun", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) runDict = [] for run in runList: runDict.append({run[0]:{"matches":run[1],"totalDistance":run[2],"averageSpeed":run[3],"HIRDistance":run[4],"sprintDistance":run[5],"HIRNumber":run[6],"sprintNumber":run[7]}}) return runDict
def get_team_foul(): foulList = service_request("GetTeamFoul", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) foulDict = [] for foul in foulList: foulDict.append({foul[0]:{"foulCommitted":foul[1],"foulSuffered":foul[2],"yellow":foul[3],"red":foul[4]}}) return foulDict
def get_best_scorers(weekid,count): week = 0 weeks = [] while week < weekid: weeks.append(week) bestList = service_request("GetBestScorers", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID,"weekList":weeks,"count":count})
def get_team_pass(): passList = service_request("GetTeamPass", {"leagueId": LEAGUE_ID, "seasonId": SEASON_ID}) passDict = [] for pas in passList: passDict.append({pas[0]:{"passTotal":pas[1],"passSuccessful":pas[2],"crossTotal":pas[3],"crossSuccessful":pas[3]}}) return passDict