@authenticated<EOL>def get_match(session, match_id):
url = '<STR_LIT>'.format(session.auth.base_url, MATCH_URL, match_id)<EOL>parsed = make_scrape_request(session, url)<EOL>game = parsed.find('<STR_LIT>').text<EOL>if game != GAME_AOC:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>date_played = parsed.find(text=MATCH_DATE_PLAYED).find_next('<STR_LIT>').text<EOL>players = []<EOL>colors = {}<EOL>player_count = int(parsed.find('<STR_LIT>', text='<STR_LIT>').find_next('<STR_LIT>').text)<EOL>for div in parsed.find_all('<STR_LIT>', style=True):<EOL><INDENT>if not div['<STR_LIT>'].startswith('<STR_LIT>'):<EOL><INDENT>continue<EOL><DEDENT>if len(players) == player_count:<EOL><INDENT>break<EOL><DEDENT>username_elem = div.find_next('<STR_LIT:a>', href=re.compile(PROFILE_PATH))<EOL>username = username_elem.text<EOL>color = div['<STR_LIT>'].split('<STR_LIT::>')[<NUM_LIT:1>].split('<STR_LIT:;>')[<NUM_LIT:0>].strip()<EOL>colors[username] = color<EOL>rec = None<EOL>for dl_elem in parsed.find_all('<STR_LIT:a>', href=re.compile('<STR_LIT>')):<EOL><INDENT>rec_name = dl_elem.find('<STR_LIT:b>', text=re.compile(username+'<STR_LIT:$>'))<EOL>if rec_name:<EOL><INDENT>rec = rec_name.parent<EOL><DEDENT><DEDENT>user = parsed.find('<STR_LIT:a>', text=username)<EOL>if not user:<EOL><INDENT>continue<EOL><DEDENT>user_id = int(user['<STR_LIT>'].split('<STR_LIT:/>')[-<NUM_LIT:1>])<EOL>children = list(user.find_next('<STR_LIT>').children)<EOL>rate_after = None<EOL>rate_before = None<EOL>if str(children[<NUM_LIT:0>]).strip() == MATCH_NEW_RATE:<EOL><INDENT>rate_after = int(children[<NUM_LIT:1>].text)<EOL>rate_before = rate_after - int(children[<NUM_LIT:3>].text)<EOL><DEDENT>elif str(children[<NUM_LIT:4>]).strip() == MATCH_NEW_RATE:<EOL><INDENT>rate_after = int(children[<NUM_LIT:5>].text)<EOL>rate_before = rate_after - int(children[<NUM_LIT:3>].text)<EOL><DEDENT>players.append({<EOL>'<STR_LIT:url>': rec['<STR_LIT>'] if rec else None,<EOL>'<STR_LIT:id>': user_id,<EOL>'<STR_LIT:username>': username,<EOL>'<STR_LIT>': COLOR_MAPPING.get(colors[username]),<EOL>'<STR_LIT>': rate_before,<EOL>'<STR_LIT>': rate_after<EOL>})<EOL><DEDENT>return {<EOL>'<STR_LIT>': dateparser.parse(date_played),<EOL>'<STR_LIT>': players<EOL>}<EOL>
Get match metadata.