From e24454eecb144770a7122895ee93c05dd03b08cc Mon Sep 17 00:00:00 2001 From: TanninOne Date: Sat, 2 Oct 2021 18:55:11 +0200 Subject: [PATCH] support for new steam config format --- README.md | 5 ++++- src/lib/steam/steam.py | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32b33cc..64cac60 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ https://github.com/TanninOne/keypirinha-allmygames/releases ## Install -Once the `allmygames.keypirinha-package` file is downloaded, +Once the `AllMyGames.keypirinha-package` file is downloaded, move it to the `InstalledPackage` folder located at: * `Keypirinha\portable\Profile\InstalledPackages` in **Portable mode** @@ -33,6 +33,9 @@ move it to the `InstalledPackage` folder located at: ## Change Log +### v1.4 +* support for new steam config format + ### v1.3 * code cleanup and log messages more standardized (thanks to ueffel) * fixed: epic manifests read with wrong encoding (thanks to ueffel) diff --git a/src/lib/steam/steam.py b/src/lib/steam/steam.py index 304ee23..c63ce59 100644 --- a/src/lib/steam/steam.py +++ b/src/lib/steam/steam.py @@ -206,6 +206,24 @@ def __get_appinfo(self, install_path: str): return reduce(to_appinfo_dict, appinfo, {}) def __get_library_paths(self, install_path: str): + if os.path.exists(os.path.join(install_path, 'config', 'libraryfolders.vdf')): + self.__context.info("new libraries format") + return self.__get_library_paths_new(install_path) + else: + self.__context.info("old libraries format") + return self.__get_library_paths_old(install_path) + + def __get_library_paths_new(self, install_path: str): + with open(os.path.join(install_path, 'config', 'libraryfolders.vdf')) as fd: + # the vdf library is case sensitive but the format actually seems to + # be case insensitive + vdict = CILookup(vdfload(fd)) + base = vdict['libraryfolders'] + return list(map( + lambda x: base[x]["path"], + filter(lambda x: x.isnumeric(), base.keys()))) + + def __get_library_paths_old(self, install_path: str): with open(os.path.join(install_path, 'config', 'config.vdf')) as fd: # the vdf library is case sensitive but the format actually seems to # be case insensitive