Add GameFinder class
This commit is contained in:
parent
426e771313
commit
67edfdf743
1 changed files with 32 additions and 0 deletions
32
src/leek/utils.py
Normal file
32
src/leek/utils.py
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue