mirror of
https://github.com/Jylpah/blitz-tools.git
synced 2026-10-23 19:19:53 +02:00
getTitle(): read tank/map names from the replay file itself
This commit is contained in:
1 parent
662171f10e
commit
66546ec57d
1 file changed
+29
-2
+29
-2
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3.8
|
#!/usr/bin/env python3.8
|
||||||
|
|
||||||
import json, argparse, inspect, sys, os, base64, aiohttp, urllib, asyncio, aiofiles, aioconsole
|
import json, argparse, inspect, sys, os, base64, aiohttp, urllib, asyncio, aiofiles, aioconsole
|
||||||
import logging, re, concurrent.futures, configparser, motor.motor_asyncio, ssl
|
import logging, re, concurrent.futures, configparser, motor.motor_asyncio, ssl, zipfile
|
||||||
import blitzutils as bu
|
import blitzutils as bu
|
||||||
from blitzutils import WG
|
from blitzutils import WG
|
||||||
from blitzutils import WoTinspector
|
from blitzutils import WoTinspector
|
||||||
@@ -231,7 +231,7 @@ async def replayWorker(queue: asyncio.Queue, workerID: int, account_id: int, pri
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def getTitle(replayfile: str, title: str, i : int) -> str:
|
def getTitle_old(replayfile: str, title: str, i : int) -> str:
|
||||||
global wg
|
global wg
|
||||||
|
|
||||||
if title == None:
|
if title == None:
|
||||||
@@ -270,6 +270,33 @@ def getTitle(replayfile: str, title: str, i : int) -> str:
|
|||||||
return title
|
return title
|
||||||
|
|
||||||
|
|
||||||
|
def getTitle(replayfile: str, title: str, i : int) -> str:
|
||||||
|
global wg
|
||||||
|
|
||||||
|
if title == None:
|
||||||
|
try:
|
||||||
|
filename = os.path.basename(replayfile)
|
||||||
|
bu.debug(filename)
|
||||||
|
player = None
|
||||||
|
tank = None
|
||||||
|
map_name = None
|
||||||
|
|
||||||
|
with zipfile.ZipFile(replayfile, 'r') as rp_archive:
|
||||||
|
with rp_archive.open('meta.json') as rp_metadata:
|
||||||
|
metadata_json = json.loads(rp_metadata)
|
||||||
|
player = metadata_json['playerName']
|
||||||
|
tank = wg.get_tank_name(metadata_json['playerVehicleName'])
|
||||||
|
map_name = wg.get_map_name(metadata_json['mapName'])
|
||||||
|
if (player != None) and (tank != None) and (map_name != None):
|
||||||
|
title = tank + ' @ ' + map_name
|
||||||
|
else:
|
||||||
|
title = re.sub('\\.wotbreplay$', '', filename)
|
||||||
|
except Exception as err:
|
||||||
|
bu.error(err)
|
||||||
|
else:
|
||||||
|
title.replace('NN', str(i))
|
||||||
|
return title
|
||||||
|
|
||||||
### main() -------------------------------------------
|
### main() -------------------------------------------
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# To avoid 'Event loop is closed' RuntimeError due to compatibility issue with aiohttp
|
# To avoid 'Event loop is closed' RuntimeError due to compatibility issue with aiohttp
|
||||||
|
|||||||
Reference in new issue
Block a user