残念ながら、Warthunderのリプレイファイルには、簡単に読みやすい情報が含まれていないようです(JSONを含むWOTなど)。これは、Warthunderリプレイファイル(.wrpl)を解析する非常に非常に基本的な試みです。 wt-toolsがありますが、それは(マルチパート)サーバーリプレイで動作しないようです。
利用可能な3つのスクリプトがあります。
ショ和 あなた自身の責任で使用する、スクレイピング(保護された)ウェブページは特定の国のTOS/法律に反している可能性があります
このスクリプトは、https://warthunder.com/en/tournament/replay/ページからリプレイをスクレイするために使用できます。このように呼び出します:
python replays_scraper.py <num_pages>
ここで、 <num_pages>スクレイプするページ数です(通常、ページごとに25のリプレイがあります)。見つかったすべてのリプレイを含むJSONオブジェクトを印刷します。
ページはログイン保護されているため、このスクリプトは、ログイン用のCookieを備えたauth_cookie.jsonファイルを期待しています。
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です(10進数または16進表記のいずれか)。これにより、Replay Filesは、HEX表記のリプレイIDにちなんで名前が付けられた名前のフォルダーに保存されます。
フォルダーにリプレイを解析します
python parse_replay.py <replay_folder>
リプレイファイルに0000.wrpl、0001.wrplなどの名前が付いていることが予想されます。 <replay_folder>が指定されていない場合、現在のディレクトリを使用します。
出力は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 ))