diff --git a/src/leek/utils.py b/src/leek/utils.py new file mode 100644 index 0000000..c1d0bac --- /dev/null +++ b/src/leek/utils.py @@ -0,0 +1,32 @@ +import vdf +from pathlib import Path + + +class GameFinder: + __game_path: Path | None = None + + @staticmethod + def find() -> Path: + if GameFinder.__game_path is not None: + return GameFinder.__game_path + + # .local/share/Steam/config/libraryfolders.vdf + steam_path: Path = Path.home() / ".local/share/Steam" + libraries_vdf_path: Path = steam_path / "config/libraryfolders.vdf" + + with libraries_vdf_path.open() as vdf_file: + data: dict = vdf.parse(vdf_file) + for index in data["libraryfolders"]: + library: dict = data["libraryfolders"][index] + + project_diva_id: str = "1761390" + if project_diva_id in library["apps"]: + libray_path: Path = Path(library["path"]) + GameFinder.__game_path = ( + libray_path + / "steamapps/common/Hatsune Miku Project DIVA Mega Mix Plus" + ) + return GameFinder.__game_path + + # Could not find the game :( + raise FileNotFoundError