From 4b31d228c6714d0084332f25df515ed30f5c2ab2 Mon Sep 17 00:00:00 2001 From: Ching Date: Fri, 15 Sep 2023 00:48:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(matches):=20=E5=A2=9E=E5=8A=A0=20matches?= =?UTF-8?q?=20file=EF=BC=8C=E8=8E=B7=E5=8F=96=E6=AF=94=E8=B5=9B=E8=AF=A6?= =?UTF-8?q?=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加 matches file,获取比赛详情 Signed-off-by: Ching --- matches.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 matches.py diff --git a/matches.py b/matches.py new file mode 100644 index 0000000..d7f00b9 --- /dev/null +++ b/matches.py @@ -0,0 +1,23 @@ +import opendota + +match_client = opendota.MatchesApi() + +def serialize_player(player): + player_data = { + 'personaname': player.personaname, + 'kills': player.kills, + 'deaths': player.deaths, + 'assists': player.assists, + 'total_gold': player.total_gold, + 'last_hits': player.last_hits, + 'denies': player.denies, + } + return player_data + +def serialize_match(match_id): + match = match_client.get_matches_by_match_id(match_id) + match_data = { + 'players': [serialize_player(player) for player in match.players], + } + return match_data +