MCPcopy Create free account
hub / github.com/BrettMayson/Arma3Server / preset

Function preset

workshop.py:12–34  ·  view source on GitHub ↗
(mod_file, client)

Source from the content-addressed store, hash-verified

10USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36" # noqa: E501
11
12def preset(mod_file, client):
13 if mod_file.startswith("http"):
14 req = urllib.request.Request(
15 mod_file,
16 headers={"User-Agent": USER_AGENT},
17 )
18 remote = urllib.request.urlopen(req)
19 with open("preset.html", "wb") as f:
20 f.write(remote.read())
21 mod_file = "preset.html"
22 mods = []
23 moddirs = []
24 with open(mod_file) as f:
25 html = f.read()
26 regex = r"filedetails\/\?id=(\d+)\""
27 matches = re.finditer(regex, html, re.MULTILINE)
28 for _, match in enumerate(matches, start=1):
29 mods.append(match.group(1))
30 api.download_workshop(client, int(match.group(1)))
31 moddirs.append("workshop/" + match.group(1))
32 for moddir in moddirs:
33 keys.copy("server/"+moddir)
34 return moddirs

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected