extract.py
· 848 B · Python
Raw
# was generated with chatgpt
import vdf
import json
def extract_launch_options(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
data = vdf.load(f)
results = []
def walk(node):
for key, val in node.items():
if isinstance(val, dict):
if key.isdigit() and "LaunchOptions" in val:
results.append({
"appid": key,
"LaunchOptions": val["LaunchOptions"]
})
walk(val)
walk(data)
return results
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser("extract")
parser.add_argument("filepath", help="the path to the VDF file to extract")
args = parser.parse_args()
print(json.dumps(extract_launch_options(args.filepath), indent=2))
| 1 | # was generated with chatgpt |
| 2 | import vdf |
| 3 | import json |
| 4 | |
| 5 | def extract_launch_options(filepath): |
| 6 | with open(filepath, 'r', encoding='utf-8') as f: |
| 7 | data = vdf.load(f) |
| 8 | |
| 9 | results = [] |
| 10 | |
| 11 | def walk(node): |
| 12 | for key, val in node.items(): |
| 13 | if isinstance(val, dict): |
| 14 | if key.isdigit() and "LaunchOptions" in val: |
| 15 | results.append({ |
| 16 | "appid": key, |
| 17 | "LaunchOptions": val["LaunchOptions"] |
| 18 | }) |
| 19 | walk(val) |
| 20 | |
| 21 | walk(data) |
| 22 | return results |
| 23 | |
| 24 | if __name__ == "__main__": |
| 25 | import argparse |
| 26 | |
| 27 | parser = argparse.ArgumentParser("extract") |
| 28 | parser.add_argument("filepath", help="the path to the VDF file to extract") |
| 29 | args = parser.parse_args() |
| 30 | |
| 31 | print(json.dumps(extract_launch_options(args.filepath), indent=2)) |
| 32 |