Skip to content

Commit

Permalink
Merge pull request #6 from Garulf/fix-handle-non-multi-lib-users
Browse files Browse the repository at this point in the history
Handle missing libraryfolders.vdf
  • Loading branch information
Garulf authored Aug 27, 2021
2 parents 4f6c531 + c91e130 commit 1f3edb3
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions plugin/steam_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
STEAM_FOLDER = os.path.join(
f"{os.environ['SYSTEMDRIVE']}\\", "Program Files (x86)", "Steam"
)
LIBRARIES = os.path.join(STEAM_FOLDER, "config", "libraryfolders.vdf")
LIBRARIES_CONFIG = os.path.join(STEAM_FOLDER, "config", "libraryfolders.vdf")
LIBRARIES_STEAMAPPS = os.path.join(STEAM_FOLDER, "steamapps", "libraryfolders.vdf")
EXE_FILTER = ["installer", "help", "skse64_loader.exe"]


Expand All @@ -33,16 +34,21 @@ def steam_folder(self):
@property
def library_paths(self):
if self._library_paths is None:
library_paths = []
library_folders = vdf.load(open(LIBRARIES, "r"))
for item in library_folders["libraryfolders"].keys():
if not isinstance(library_folders["libraryfolders"][item], str):
library_paths.append(
library_folders["libraryfolders"][item]["path"]
)
library_paths.append(
self._steam_folder
)
library_paths = [self._steam_folder]
if Path(LIBRARIES_CONFIG).exists():
steamlibrary_config = LIBRARIES_CONFIG
else:
steamlibrary_config = LIBRARIES_STEAMAPPS
try:
library_folders = vdf.load(open(steamlibrary_config, "r"))
except FileNotFoundError:
pass
else:
for item in library_folders["libraryfolders"].keys():
if not isinstance(library_folders["libraryfolders"][item], str):
library_paths.append(
library_folders["libraryfolders"][item]["path"]
)
self._library_paths = library_paths
return self._library_paths

Expand Down Expand Up @@ -114,8 +120,8 @@ def query(self, query):
title=game["name"],
subtitle=game["install_dir"],
icon=icon,
method='launch_game',
parameters=[game["id"]]
method="launch_game",
parameters=[game["id"]],
)

def launch_game(self, game_id):
Expand Down

0 comments on commit 1f3edb3

Please sign in to comment.