Add GameFinder class

This commit is contained in:
Toast 2025-06-02 01:21:55 +02:00
parent 426e771313
commit 67edfdf743

32
src/leek/utils.py Normal file
View file

@ -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