Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- import subprocess
- import requests
- import keys
- WORKSHOP = "steamapps/workshop/content/107410/"
- USER_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
- def download(mods):
- steamcmd = ["/steamcmd/steamcmd.sh"]
- steamcmd.extend(
- [
- "+force_install_dir",
- "/arma3",
- "+login",
- os.environ["STEAM_USERNAME"],
- os.environ["STEAM_PASSWORD"],
- ]
- )
- for id in mods:
- steamcmd.extend(["+workshop_download_item", "107410", id])
- steamcmd.extend(["+quit"])
- subprocess.call(steamcmd)
- def preset(mod_file):
- if mod_file.startswith("http"):
- response = requests.get(mod_file, headers={"User-Agent": USER_AGENT})
- with open("preset.html", "wb") as f:
- f.write(response.content)
- mod_file = "preset.html"
- mods = []
- moddirs = []
- with open(mod_file) as f:
- html = f.read()
- regex = r"filedetails\/\?id=(\d+)\""
- matches = re.finditer(regex, html, re.MULTILINE)
- for _, match in enumerate(matches, start=1):
- mods.append(match.group(1))
- moddir = WORKSHOP + match.group(1)
- moddirs.append(moddir)
- download(mods)
- for moddir in moddirs:
- keys.copy(moddir)
- return moddirs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement