Last active
August 9, 2025 06:25
-
-
Save NadnerbD/193484b9ac1a0b9e622feed5c332da48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import OrderedDict | |
| import re, json, sys, os | |
| def parseObj(tokens): | |
| if(type(tokens) == str): | |
| tokens = re.split(r'[\t\r\n]+', tokens) | |
| tokens.reverse() | |
| obj = OrderedDict() | |
| while len(tokens): | |
| nt = tokens.pop() | |
| if nt in ["}", ""]: | |
| return obj | |
| elif nt.startswith('"'): | |
| nt = json.loads(nt) | |
| val = tokens.pop() | |
| if val.startswith('"'): | |
| obj[nt] = json.loads(val) | |
| elif val == "{": | |
| obj[nt] = parseObj(tokens) | |
| else: | |
| raise Exception("nt = %r" % nt) | |
| def dumpObj(obj, indent=0): | |
| s = "" | |
| for key in obj: | |
| s += "\t" * indent + json.dumps(key) | |
| if type(obj[key]) == OrderedDict: | |
| s += "\n" + "\t" * indent + "{\n" + dumpObj(obj[key], indent + 1) + "\t" * indent + "}\n" | |
| else: | |
| s += "\t\t%s\n" % json.dumps(obj[key]) | |
| return s | |
| with open(sys.argv[1], "r") as f: | |
| manifestpath = os.path.dirname(f.name) | |
| data = f.read() | |
| manifest = parseObj(data) | |
| print(dumpObj(manifest)) | |
| if "-username" in sys.argv: | |
| username = sys.argv[sys.argv.index("-username") + 1] | |
| appstate = manifest['AppState'] | |
| for depotkey in appstate['StagedDepots']: | |
| cmd = \ | |
| "DepotDownloader.exe -app " + appstate['appid'] + \ | |
| " -depot " + depotkey + " -manifest " + appstate['StagedDepots'][depotkey]['manifest'] + \ | |
| " -username " + username + " -remember-password -dir \"" + \ | |
| manifestpath + "\\common\\" + appstate['installdir'] + "\" -validate" | |
| print(cmd) | |
| os.system(cmd) | |
| installed_depot = appstate['StagedDepots'][depotkey] | |
| del installed_depot['dlcappid'] | |
| appstate['InstalledDepots'][depotkey] = installed_depot | |
| del appstate['StagedDepots'][depotkey] | |
| appstate['StateFlags'] = "4" | |
| appstate['UpdateResult'] = "0" | |
| appstate['StagingSize'] = "0" | |
| appstate['buildid'] = appstate['TargetBuildID'] | |
| appstate['BytesStaged'] = appstate['BytesToStage'] | |
| appstate['BytesDownloaded'] = appstate['BytesToDownload'] | |
| print(dumpObj(manifest)) | |
| with open(sys.argv[1], "w") as f: | |
| f.write(dumpObj(manifest)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, so you didn't need an answer for your question what is KeyError: 'StagedDepots'? cool :)