From 9f832feb945d7d72c70d906afeef5f231874c661 Mon Sep 17 00:00:00 2001 From: KeksNino Date: Wed, 1 Jan 2025 00:39:39 +0100 Subject: [PATCH] fetch save file location for appid --- main.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..3130653 --- /dev/null +++ b/main.py @@ -0,0 +1,41 @@ +import subprocess +import sys +import re + +def get_app_info(appid): + result = subprocess.run( + ["steamcmd", "+login", "anonymous", "+app_info_request", str(appid), "+login", "anonymous", "+app_info_print", str(appid), "+logoff", "+quit"], + capture_output=True, + text=True, + encoding='utf-8' + ) + return result.stdout + +def extract_paths_and_roots(app_info): + paths_and_roots = re.findall(r'"root"\s+"([^"]+)"|"path"\s+"([^"]+)"', app_info) + return paths_and_roots + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python main.py ") + sys.exit(1) + + appid = sys.argv[1] + app_info = get_app_info(appid) + paths_and_roots = extract_paths_and_roots(app_info) + + current_root = None + for match in paths_and_roots: + root, path = match + if root: + if root == "WinMyDocuments": + current_root = r"%UserProfile%\Documents" + elif root == "WinAppDataLocal": + current_root = r"%Localappdata%" + elif root == "gameinstall": + current_root = r"Steam Library\steamapps\common\gamename" + else: + current_root = root + if path: + combined_path = f"{current_root}\\{path}".replace('/', '\\') + print(combined_path) \ No newline at end of file