fix: support new Steam cover layout

This commit is contained in:
strsv committed 2026-11-06 06:35:33 +03:00
1 parent e433ca3842
commit 0784d4c143
12 files changed
+212 -88

No files matched your search

+40
View File
@@ -43,6 +43,46 @@ DEFAULT_ROOTS = (
r"C:\Program Files\Steam",
)
COVER_ORDER = (
"library_600x900.jpg",
"library_capsule.jpg",
"header.jpg",
"library_header.jpg",
"library_hero.jpg",
"logo.png",
)
def find_cover(appid, lib_cache):
"""Find a cover in both Steam librarycache layouts.
Newer clients store art in hashed subdirectories:
<appid>/<hash>/library_capsule.jpg
Older clients use flat names:
<appid>/library_600x900.jpg
"""
if not lib_cache:
return None
app_dir = os.path.join(lib_cache, str(appid))
if not os.path.isdir(app_dir):
return None
try:
dirs = [app_dir]
for sub in os.listdir(app_dir):
sub_dir = os.path.join(app_dir, sub)
if os.path.isdir(sub_dir):
dirs.append(sub_dir)
# Prefer the best cover type across every layout, not the first
# subdirectory that happens to contain any image.
for name in COVER_ORDER:
for directory in dirs:
path = os.path.join(directory, name)
if os.path.isfile(path):
return path
except OSError:
return None
return None
def find_steam_root():
try: