Skip to content

Commit da00ac1

Browse files
authored
Merge pull request #7 from Garulf/fix-handle-different-libraryfolders
* handle "older" and "newer" libraries vdf file
2 parents 8a36c37 + 4c482f5 commit da00ac1

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

plugin/steam_search.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,30 @@ def steam_folder(self):
3434
@property
3535
def library_paths(self):
3636
if self._library_paths is None:
37+
steam_libraries = (
38+
LIBRARIES_CONFIG
39+
if Path(LIBRARIES_CONFIG).exists()
40+
else LIBRARIES_STEAMAPPS
41+
)
3742
library_paths = [self._steam_folder]
38-
if Path(LIBRARIES_CONFIG).exists():
39-
steamlibrary_config = LIBRARIES_CONFIG
40-
else:
41-
steamlibrary_config = LIBRARIES_STEAMAPPS
4243
try:
43-
library_folders = vdf.load(open(steamlibrary_config, "r"))
44+
library_folders = vdf.load(open(steam_libraries, "r"))
4445
except FileNotFoundError:
4546
pass
4647
else:
47-
for item in library_folders["libraryfolders"].keys():
48-
if not isinstance(library_folders["libraryfolders"][item], str):
49-
library_paths.append(
50-
library_folders["libraryfolders"][item]["path"]
51-
)
48+
if library_folders.get("libraryfolders"):
49+
libraries_key = "libraryfolders"
50+
else:
51+
libraries_key = "LibraryFolders"
52+
for item in library_folders[libraries_key].keys():
53+
if item.isdigit():
54+
try:
55+
library_paths.append(
56+
library_folders[libraries_key][item]["path"]
57+
)
58+
except TypeError:
59+
library_paths.append(library_folders[libraries_key][item])
60+
5261
self._library_paths = library_paths
5362
return self._library_paths
5463

0 commit comments

Comments
 (0)