return match_tel def store_tel_data(data, id): """ Given a telemetry object store relevant data :param data: :return: """ l = data.events_from_type('LogPlayerKill') for events in l: logging.log(logging.INFO, 'storing player kill data') d.store_tel_data(events, id) test = api.samples().get() for id in test.matches: tel = get_telemetry_data(id.id) store_tel_data(tel, id.id) """ m = load_json_from_file('') for a in m['data']['relationships']['matches']['data']: d.store_match_id(a['id']) games_played = get_games_from_player_name("NZWookie") store_match_id(games_played)
conn = pymysql.connect(host='localhost', port=3306, user='******', password='******', database='pubg2') cursor = conn.cursor() sql = 'SELECT match_id from game' cursor.execute(sql) extra_base_id_list = [i[0] for i in cursor.fetchall()] older_ids = base_id_list + extra_base_id_list older_ids = list(set(older_ids)) print(older_ids) while True: sample = api.samples().get() matchidlist = [match.id for match in sample.matches] matchidlist = older_ids + matchidlist conn, cursor = utfcon() cursor.execute('SELECT match_id from game') previous_entries = [i[0] for i in cursor.fetchall()] matchidlist = [i for i in matchidlist if i not in previous_entries] id_length = len(matchidlist) start = 0 stop = 100 inc = 50 while id_length > 0:
def main(): shardName = 'STEAM' charaNameIndex = [] charaIdIndex = [] charaPositionXIndex = [] charaPositionYIndex = [] charaPositionZIndex = [] charaRankIndex = [] elapsedTimeIndex = [] playerDeadPositionIndex = [] killPlayerPositionIndex = [] playerKillCountIndex = [] playerLandingPositionIndex = [] zoneElapsedTimeIndex = [] safetyZonePositionXIndex = [] safetyZonePositionYIndex = [] safetyZoneRadiusIndex = [] poisonGasPositionXIndex = [] poisonGasPositionYIndex = [] poisonGasRadiusIndex = [] airLineAlpha = 0 airLineBeta = 0 airLineFirstPositionIndex = [] airLineEndPositionIndex = [] airLineFirstPos = [] matchDay = "" api = PUBG('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJiMGVhNmM0MC1kNGQzLTAxMzYtYmQ3ZC03MzkyZGYzNjZhZTAiLCJpc3MiOiJnYW1lbG9ja2VyIiwiaWF0IjoxNTQzMzY1NDQxLCJwdWIiOiJibHVlaG9sZSIsInRpdGxlIjoicHViZyIsImFwcCI6InlvdXJpNDAxIn0.Z9i2twdF8yDkSPQ2DVjy1jbr7E5PbtiiB9n3UgfyKCg', Shard.STEAM) sample = api.samples().get() for i in range(len(sample.matches)): try: matchId = sample.matches[i].id match = api.matches().get(matchId) asset = match.assets[0] telemetry = api.telemetry(asset.url) log_match_start = telemetry.events_from_type('LogMatchStart') log_player_position = telemetry.events_from_type('LogPlayerPosition') if not(log_match_start[0].map_name == "Range_Main"): if not(log_match_start[0].is_event_mode): map = getMapImg(log_match_start[0].map_name) player = getPlayersPositonInfo(map,telemetry) matchDay = match.attributes["createdAt"] customMatchFlag = log_match_start[0].is_custom_game charaNameIndex,charaIdIndex,charaPositionXIndex,charaPositionYIndex,charaPositionZIndex,charaRankIndex,elapsedTimeIndex = player.getAllPlayersAllInfo() playerDeadPositionIndex,killPlayerPositionIndex,playerKillCountIndex = player.getPlayerKillDeadPosition(charaIdIndex,charaRankIndex) playerLandingPositionIndex = player.getPlayerLandingPosition(charaIdIndex) instanceMatch = getMatchInfo(telemetry) zoneElapsedTimeIndex,safetyZonePositionXIndex,safetyZonePositionYIndex,safetyZoneRadiusIndex,poisonGasPositionXIndex,poisonGasPositionYIndex,poisonGasRadiusIndex = instanceMatch.getSafetyAndPoisonGasPosInfo() airLineAlpha,airLineBeta,airLineFirstPositionIndex,airLineEndPositionIndex = instanceMatch.getAirPlaneInfo(map) wpIndex = makePlayerWriteIndex(charaNameIndex,charaIdIndex,charaRankIndex,playerLandingPositionIndex,elapsedTimeIndex,charaPositionXIndex,charaPositionYIndex,charaPositionZIndex,playerDeadPositionIndex,killPlayerPositionIndex,playerKillCountIndex,match.id) wmIndex = makeMatchWriteIndex(match.map_name,match.game_mode,match.id,matchDay,customMatchFlag,airLineAlpha,airLineBeta,airLineFirstPositionIndex,airLineEndPositionIndex,zoneElapsedTimeIndex,safetyZonePositionXIndex,safetyZonePositionYIndex,safetyZoneRadiusIndex,poisonGasPositionXIndex,poisonGasPositionYIndex,poisonGasRadiusIndex,shardName) print(str(i)+"/"+str(len(sample.matches))+" : "+match.map_name) writePlayerCsv(wpIndex,match.map_name,match.game_mode) writeMatchCsv(wmIndex) else: print(str(i)+" : this match is EventMode") else: print(str(i)+"/"+str(len(sample.matches))+" : this match is Range_Main") except Exception as e: print(e)
from pubg_python import PUBG, Shard from chicken_dinner.pubgapi import PUBGCore import math apikey = open("PUBGAPIKEY.txt").read().strip() #Authentication of API KEY api = PUBG(apikey, Shard.PC_NA) #Get a sample of matches played starting from 2019 May 23rd, at 12am sample = api.samples().filter(created_at_start='2019-05-23T00:00:00Z').get() Match = [] for match in sample.matches: Match.append(match) runtime = 0 runtime1 = 0 while runtime < 100: #Number of matches will be tested Name = [] player = [] X1 = [] X2 = [] X3 = [] X4 = [] X5 = [] X = [] XX = [] Damage = [] Head = [] Long = [] Kill = [] TimeS = []