From b869655086ca2139a532d5633d858e6fff2ccbfc Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 30 Dec 2019 00:45:03 +0100 Subject: Proper parsing of TC JSON participant groups --- jfr_playoff/tournamentinfo/tcjson.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'jfr_playoff') diff --git a/jfr_playoff/tournamentinfo/tcjson.py b/jfr_playoff/tournamentinfo/tcjson.py index 039a9b0..775183e 100644 --- a/jfr_playoff/tournamentinfo/tcjson.py +++ b/jfr_playoff/tournamentinfo/tcjson.py @@ -36,7 +36,15 @@ class TCJsonTournamentInfo(TournamentInfoClient): results = [] results_json = json.loads( p_remote.fetch_raw(self.get_results_link('results.json'))) + participant_groups = [] for result in results_json['Results']: + group = result['ParticipantGroup'] + if group is not None: + if group not in participant_groups: + participant_groups.append(group) + group_id = participant_groups.index(group) + 1 + else: + group_id = 999999 participant = result['Participant'] flag_url = None flag = participant['_flag'] @@ -46,7 +54,7 @@ class TCJsonTournamentInfo(TournamentInfoClient): if flag['IsCustom'] else '%s/%s.png' % (FLAG_CDN_URL, flag['CountryNameCode'])) results.append(( - result['ParticipantGroup'], result['Place'], + group_id, result['Place'], participant['_name'], participant['_shortName'], flag_url)) PlayoffLogger.get('tcjson').info( -- cgit v1.2.3