Skip to content

Instantly share code, notes, and snippets.

@miceiken
Created May 20, 2019 19:26
Show Gist options
  • Save miceiken/abb8c627203c09aa8e8d7cdbacb66729 to your computer and use it in GitHub Desktop.
Save miceiken/abb8c627203c09aa8e8d7cdbacb66729 to your computer and use it in GitHub Desktop.
Install WoW Classic Beta (despite not being invited)
import requests
import socket
from contextlib import closing
HOST = "localhost"
def find_port():
ports = [1120] + list(range(6881, 9))
return next((port for port in ports if is_port_open(port)))
def is_port_open(port):
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
return sock.connect_ex((HOST, port)) == 0
class BNAClient():
def __init__(self, base_url):
self.base_url = base_url
self.session = requests.Session()
self.session.headers.update({"User-Agent": "phoenix-agent/1.0"})
def authorize(self):
res = self.session.get(f"{self.base_url}/agent").json()
self.session.headers.update({"Authorization": res["authorization"]})
BETA_REQUEST = """
{
"instructions_dataset" : [
"torrent",
"win",
"wow_classic_beta",
"enus"
],
"instructions_patch_url" : "http://eu.patch.battle.net:1119/wow_classic_beta",
"instructions_product" : "NGDP",
"monitor_pid" : 12345.000000,
"priority" : {
"insert_at_head" : false,
"value" : 900.000000
},
"uid" : "wow_classic_beta"
}
"""
BETA_REQUEST2 = """
{
"eula" : true,
"game_dir" : "D:/Games/WoW Classic Beta",
"language" : [
"enUS"
],
"selected_asset_locale" : "enUS",
"selected_locale" : "enUS",
"shortcut" : "all",
"tome_torrent" : "",
"finalized" : true
}
"""
if __name__ == "__main__":
(host, port) = "localhost", find_port()
client = BNAClient(f"http://{host}:{port}")
client.authorize()
print(client.session.post(
f"{client.base_url}/install", BETA_REQUEST).json())
print(client.session.post(
f"{client.base_url}/install/wow_classic_beta", BETA_REQUEST2).json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment