mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-23 10:26:19 +01:00
Wraps depotdownloader for the bulk content pull (bypasses Steam's own capped download speed) and steamcmd's app_update --validate to make Steam recognize the result, with a manual-manifest fallback for the confirmed steamcmd install-script segfault bug when no fix is available. Name search via store.steampowered.com is best-effort since that endpoint TLS-rejects scripted clients on this network; --appid plus steamcmd's own app_info_print is the reliable primary path. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
"""Look up app metadata via steamcmd's app_info_print (anonymous, no login needed)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
import subprocess
|
|
from dataclasses import dataclass
|
|
|
|
from steam_installer import vdf
|
|
|
|
|
|
class AppInfoError(Exception):
|
|
pass
|
|
|
|
|
|
@dataclass
|
|
class AppMetadata:
|
|
appid: int
|
|
name: str
|
|
installdir: str
|
|
|
|
|
|
def _fetch_app_block(appid: int) -> dict:
|
|
result = subprocess.run(
|
|
["steamcmd", "+login", "anonymous", "+app_info_print", str(appid), "+quit"],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=60,
|
|
)
|
|
output = result.stdout
|
|
# app_info_print emits `"<appid>"\n{ ... }` inside a stream of steamcmd's own log lines;
|
|
# slice from the first line that starts the VDF block onward.
|
|
match = re.search(rf'^"{appid}"\s*$', output, re.MULTILINE)
|
|
if not match:
|
|
raise AppInfoError(f"steamcmd did not return app info for {appid}:\n{output}")
|
|
data = vdf.parse(output[match.start() :])
|
|
app_block = data.get(str(appid), {})
|
|
if not isinstance(app_block, dict):
|
|
raise AppInfoError(f"unexpected app_info_print structure for {appid}")
|
|
return app_block
|
|
|
|
|
|
def get_metadata(appid: int) -> AppMetadata:
|
|
"""Fetch the fields this project actually needs: display name and installdir."""
|
|
app_block = _fetch_app_block(appid)
|
|
common = app_block.get("common", {})
|
|
if not isinstance(common, dict):
|
|
raise AppInfoError(f"no 'common' section in app info for {appid}")
|
|
|
|
name = common.get("name")
|
|
if not isinstance(name, str):
|
|
raise AppInfoError(f"no name field found for app {appid}")
|
|
|
|
installdir = common.get("installdir")
|
|
if not isinstance(installdir, str):
|
|
config = app_block.get("config", {})
|
|
installdir = config.get("installdir") if isinstance(config, dict) else None
|
|
if not isinstance(installdir, str):
|
|
raise AppInfoError(f"no installdir field found for app {appid}")
|
|
|
|
return AppMetadata(appid=appid, name=name, installdir=installdir)
|