-
Notifications
You must be signed in to change notification settings - Fork 0
/
steam_appmanifest_selenium.py
74 lines (66 loc) · 1.74 KB
/
steam_appmanifest_selenium.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# steam_appmanifest_selenium.py
from pathlib import Path
from selenium import webdriver
def get_appid() -> str:
while True:
appid = input("Enter appid: ")
if appid.isdigit():
return appid
else:
print("Invalid appid.\n")
def get_details(id: str) -> (str, str):
# using chrome webdriver
driver = webdriver.Chrome()
try:
driver.get(f"https://steamdb.info/app/{id}/config/")
assert "No app was found matching this AppID." not in driver.page_source
except:
print("Invalid appid.")
raise
else:
name = driver.find_element_by_xpath \
("/html/body/div[1]/div[1]/div[2]/div/div/div[1]/h1").text
installdir = driver.find_element_by_xpath \
("//*[contains(text(), \"installdir\")]/following-sibling::td").text
return (name, installdir)
finally:
driver.close()
def create_manifest(appid: str, name: str, installdir: str):
manifest = f"""\
"AppState"
{{
"appid" "{appid}"
"Universe" "1"
"name" "{name}"
"StateFlags" "4"
"installdir" "{installdir}"
"LastUpdated" "0"
"UpdateResult" "0"
"SizeOnDisk" "0"
"buildid" "0"
"LastOwner" "0"
"BytesToDownload" "0"
"BytesDownloaded" "0"
"AutoUpdateBehavior" "0"
"AllowOtherDownloadsWhileRunning" "0"
"ScheduledAutoUpdate" "0"
"InstalledDepots"
{{
}}
"MountedDepots"
{{
}}
"UserConfig"
{{
}}
}}
"""
p = Path(f'appmanifest_{appid}.acf')
p.write_text(manifest)
print("\n" + p.read_text())
def run():
appid = get_appid()
name, installdir = get_details(appid)
create_manifest(appid, name, installdir)
if __name__ == "__main__":
run()