From 4f42a2b0701883d03c90677b156308af8cef7f99 Mon Sep 17 00:00:00 2001 From: Yoshi_E Date: Sun, 3 Dec 2017 00:24:12 +0100 Subject: [PATCH] Added new command "extract" to extract the json data from a single replay to a json file --- README.md | 4 +++- WowsReplayTool.py | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8371bdc..d0a012c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ # WorldofWarshipsScripts A collection of useful, or not so useful scripts and tools -This releases can be found here: https://github.com/Yoshi-EE/WorldofWarshipsScripts/releases \ No newline at end of file +This releases can be found here: https://github.com/Yoshi-EE/WorldofWarshipsScripts/releases + +More changes coming soon. \ No newline at end of file diff --git a/WowsReplayTool.py b/WowsReplayTool.py index 7e2cc95..dda14d3 100644 --- a/WowsReplayTool.py +++ b/WowsReplayTool.py @@ -28,9 +28,10 @@ epilog="") parser.add_argument('-path', nargs=1, help='Path to replay Folder, default = current_path', default=os.path.dirname(os.path.realpath(__file__))+"/") +parser.add_argument('-extract', nargs=1, help='Path to replay file, default = current_path', default="") parser.add_argument('--wait', help='Waits before closing window, default = False', action='store_const', const=True, default=False) parser.add_argument('-app_id', nargs=1, help='Wargaming API ID (developers.wargaming.net), default is given', default="23c72eadf6267847fc48a35d03bdb2ef") -parser.add_argument('-output', nargs=1, help='Path to cvs files, default = binary_path', default=os.path.dirname(os.path.realpath(__file__))+"/") +parser.add_argument('-output', nargs=1, help='universal output path, default = binary_path', default=os.path.dirname(os.path.realpath(__file__))+"/") parser.add_argument('-prefix', nargs=1, help='Prefix for cvs files, default = None', default="") parser.add_argument('--Random', help='Tracks Random Games, default = False', action='store_const', const=True, default=False) parser.add_argument('--Coop', help='Tracks Coop Games, default = False', action='store_const', const=True, default=False) @@ -67,7 +68,7 @@ #If In script: if("Python" in shipDB_path): shipDB_path = os.path.dirname(os.path.realpath(__file__))+"/" - + print("Replay path: "+default_path) print("CVS path: "+cvs_output) print("ShipDB path: "+shipDB_path) @@ -167,8 +168,23 @@ def calcAvrg(A,B): return (("%.2f" % (float(A) / B)).replace(".",",")) else: return 0 + + + +def extractReplay(path): + jsonData = loadReplay(path) + with open(cvs_output+os.path.basename(path)+".json", "w") as outfile: + json.dump(jsonData, outfile) + print("Extracted replay to: "+cvs_output+os.path.basename(path)+".json") + + +if(args['extract'] != ""): + extractReplay(''.join(args['extract'])) + sys.exit() #Program stats here :) + + askForDatabase() #Ensures you have the information about the ships replayFiles = getFiles(default_path) #Gets a List with all replay file paths shipDatabase = loadShipDatbase() #Loads Database from file