Warthunder Replay Files น่าเสียดายที่ดูเหมือนจะไม่มีข้อมูลที่อ่านได้ง่าย (เช่น WOT ซึ่งรวมถึง JSON บางส่วน) นี่เป็นความพยายามขั้นพื้นฐานที่มากในการแยกวิเคราะห์ไฟล์เล่นซ้ำ Warthunder (.WRPL) มีเครื่องมือ WT ซึ่งดูเหมือนจะไม่ทำงานกับเซิร์ฟเวอร์ (Multipart) Replay
มีสามสคริปต์ให้เลือก:
ใช้ความเสี่ยงของคุณเองการขูด (ป้องกัน) หน้าเว็บอาจขัดต่อ TOS/กฎหมายในบางประเทศ
สคริปต์นี้สามารถใช้เพื่อขูดซ้ำจาก https://warthunder.com/en/tournament/replay/ หน้า เรียกมันแบบนี้:
python replays_scraper.py <num_pages>
โดยที่ <num_pages> คือจำนวนหน้าเพื่อขูด (โดยทั่วไปจะมี 25 ครั้งต่อหน้า) มันจะพิมพ์วัตถุ JSON พร้อมรีเพลย์ที่พบทั้งหมด
เนื่องจากหน้านี้ได้รับการป้องกันการเข้าสู่ระบบสคริปต์นี้จึงคาดว่าไฟล์ auth_cookie.json พร้อมคุกกี้สำหรับการเข้าสู่ระบบ:
auth_cookie.json:
{
"identity_sid" : " ... "
} ที่ไหน ... คุณค่าของคุกกี้ identity_sid (ซึ่งคุณสามารถรับได้โดยลงชื่อเข้าใช้ Warthunder.com และอ่านคุกกี้ในเบราว์เซอร์ของคุณ)
ดาวน์โหลดการเล่นซ้ำจาก https://warthunder.com/en/tournament/replay/
python download_replay.py <replay_id>
โดยที่ <replay_id> เป็น ID เล่นซ้ำ (64 บิตไม่ว่าจะเป็นสัญลักษณ์ทศนิยมหรือเลขฐานสิบหก) สิ่งนี้จะจัดเก็บไฟล์เล่นซ้ำในโฟลเดอร์ที่ชื่อหลังจากเล่นซ้ำ ID ในสัญลักษณ์ Hex
แยกวิเคราะห์การเล่นซ้ำในโฟลเดอร์
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 ))