19 lines
601 B
Python
19 lines
601 B
Python
import opendota
|
|
import datetime
|
|
import players
|
|
import utils
|
|
|
|
match_client = opendota.MatchesApi()
|
|
|
|
def serialize_match(match_id):
|
|
match = match_client.get_matches_by_match_id(match_id)
|
|
match_data = {
|
|
'players': [players.serialize_player(player) for player in match.players],
|
|
'dire_score': match.dire_score,
|
|
'radiant_score': match.radiant_score,
|
|
'start_time': datetime.datetime.fromtimestamp(match.start_time).strftime('%Y-%m-%d %H:%M:%S'),
|
|
'duration': '%d:%02d:%02d' % utils.convert_seconds_to_hms(match.duration),
|
|
'radiant_win': match.radiant_win,
|
|
}
|
|
return match_data
|