steam-backlog-enforcer/steam_installer/dlc.py
Krzysztof kuhy Rudnicki a76e726e36 Merge steam-game-installer into the repo
The installer ships as the steam_installer package beside
steam_backlog_enforcer, with its tests, docs and Proton lock. The
enforcer's fast install now starts the installer from this checkout.

Both appinfo.vdf readers share one key-value decoder
(steam_installer.appinfo_kv), and the duplicated test fixtures and
helpers are folded into conftest and _cli_helpers so the whole-tree
duplicate-code check is clean. check_requirements_sync treats sibling
packages as first-party.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWZCxnNWLtpVwFLVk9w
2026-11-22 20:25:39 +01:00

50 lines
2.1 KiB
Python

"""Owned DLC that ships as an app of its own, fetched next to the base game.
depotdownloader's `-app <game>` run only walks the game's own depot list. DLC
such as Cyberpunk 2077's Phantom Liberty (app 2138330, ~25 GB) keeps its depot
under its own app id, so that run never touches it -- and the Steam client,
restarted onto a manifest without it, then downloaded all 24 GB at its own
pace. Each such DLC now gets a depotdownloader run of its own into the same
install dir, where the manifest step picks its depot up from the cache.
Ownership is left to depotdownloader's licence check. Its refusal is the one
failure that is expected (games list DLC nobody bought); anything else aborts
the install before the manifest is touched, like a failed base download.
"""
from __future__ import annotations
from steam_installer import appinfo, depotdl, runlog
def download_owned(
appid: int, pull: depotdl.Pull, log: runlog.RunLog
) -> appinfo.DepotPlan | None:
"""Download every owned DLC of `appid` that has depots of its own.
Returns:
The DLC depots now downloaded -- each credited to its DLC app, with
its public gid -- or None if a DLC download failed for a reason other
than not owning it.
"""
logger = log.logger
plans = appinfo.get_dlc_plans(appid, pull.language)
downloaded = appinfo.DepotPlan(required=set(), shared=set())
for dlc_appid, depots in sorted(plans.items()):
log.section(f"depotdownloader DLC {dlc_appid}")
outcome = depotdl.download_dlc(dlc_appid=dlc_appid, pull=pull, logger=logger)
if outcome is None:
logger.info("DLC %d is not owned by this account -- skipped.", dlc_appid)
continue
if not outcome:
logger.error(
"depotdownloader failed for DLC %d -- not touching the manifest.",
dlc_appid,
)
return None
logger.info("Downloaded DLC %d (depots %s).", dlc_appid, sorted(depots))
downloaded.required |= set(depots)
downloaded.dlc.update(dict.fromkeys(depots, str(dlc_appid)))
downloaded.manifests.update(depots)
return downloaded