warthunder replay parser
1.0.0
不幸的是,Warthunder重播文件似乎不包含任何易於閱讀的信息(例如WOT,其中包括一些JSON)。這是解析Warthunder重播文件(.wrpl)的非常非常基本的嘗試。有WT-Tools,儘管它似乎與(Multipart)服務器重播似乎不起作用。
有三個腳本可用:
配x 出於您自己的風險使用,在某些國家/地區刮擦(受保護的)網頁可能會違反TOS/LAW
該腳本可用於從https://warthunder.com/en/tournament/replay/ page刮下來。這樣調用:
python replays_scraper.py <num_pages>
其中<num_pages>是要刮擦的頁面數(通常每個頁面有25個重播)。它將用所有發現的重播打印一個JSON對象。
由於該頁面受登錄保護,因此該腳本期望一個auth_cookie.json文件,登錄名:cookie:
auth_cookie.json:
{
"identity_sid" : " ... "
}在哪裡...是identity_sid cookie的價值(您可以通過登錄Warthunder.com並閱讀瀏覽器中的cookie來獲得。
從https://warthunder.com/en/tournament/replay/下載重播。
python download_replay.py <replay_id>
其中<replay_id>是重播ID(64位,分數為十進製或十六進制符號)。這將將重播文件存儲在一個文件夾中,以十六進製表示法中的重播ID命名。
在文件夾中解析重播
python parse_replay.py <replay_folder>
它希望重播文件命名<replay_folder> 0000.wrpl,0001.wrpl等。
輸出將以JSON形式:
parsing replay in /path/to/replay/005569aa001501ca
parsing /path/to/replay/005569aa001501ca/0000.wrpl
parsing /path/to/replay/005569aa001501ca/0001.wrpl
parsing /path/to/replay/005569aa001501ca/0002.wrpl
parsing /path/to/replay/005569aa001501ca/0003.wrpl
parsing /path/to/replay/005569aa001501ca/0004.wrpl
parsing /path/to/replay/005569aa001501ca/0005.wrpl
parsing /path/to/replay/005569aa001501ca/0006.wrpl
parsing /path/to/replay/005569aa001501ca/0007.wrpl
parsing /path/to/replay/005569aa001501ca/0008.wrpl
parsing /path/to/replay/005569aa001501ca/0009.wrpl
{
"level": "levels/avg_normandy.bin",
"mission_file": "gamedata/missions/cta/tanks/normandy/normandy_dom.blk",
"mission_name": "normandy_Dom",
"time_of_day": "day",
"weather": "hazy",
"time_of_battle_ts": 1641217514,
"time_of_battle": "2022-01-03 14:45:14",
"num_players": 21,
"players": [
{
"player_id": 34,
"vehicles": [
"us_m1a1_abrams",
"us_m1a1_hc_abrams"
]
},
{
"player_id": 35,
"vehicles": [
"us_m1_ip_abrams",
"us_hstv_l"
]
},
...
]
}
您也可以將腳本用作模塊
import replays_scraper
import download_replay
import parse_replay
# set the cookies
cookies = { "identity_sid" : "secret_key" }
# download the html
pages = replays_scraper . download_pages ( 1 , cookies )
# scrape replay data from html
replays = []
for page in pages :
replays += replays_scraper . parse_page ( page )
# download the files of the last replay
download_replay . downloadReplay ( replays [ - 1 ][ "id" ])
# get the hexadecimal id (= folder name)
replay_id_hex = download_replay . _get_hex_id ( replays [ - 1 ][ "id" ])
# parse the replay
print ( parse_replay . parse_replay ( replay_id_hex ))