Skip to content

Commit 2292ca9

Browse files
committed
1 parent e887faa commit 2292ca9

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

steam/manifest.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import struct
1111
import sys
1212
from base64 import b64decode
13-
from collections.abc import AsyncGenerator, Generator, Sequence
13+
from collections.abc import AsyncGenerator, Generator, Mapping, Sequence
1414
from contextlib import asynccontextmanager
1515
from dataclasses import dataclass, field
1616
from datetime import datetime
@@ -777,6 +777,14 @@ def is_depot(item: tuple[str, Any]) -> TypeGuard[tuple[str, manifest.Depot]]:
777777
return True
778778

779779

780+
def maybe_get(map: Mapping[str, str | None] | str, key: str) -> int | None:
781+
if isinstance(map, str):
782+
return int(map)
783+
value = map.get(key)
784+
if value is not None:
785+
return int(value)
786+
787+
780788
class AppInfo(ProductInfo, PartialApp[str]):
781789
"""Represents a collection of information on an app."""
782790

@@ -930,17 +938,32 @@ def __init__(
930938
)
931939
)
932940
else:
933-
for branch_name, manifest_id in manifests.items():
941+
public_manifest_info = manifests["public"]
942+
public_id = ManifestID(
943+
int(public_manifest_info if isinstance(public_manifest_info, str) else public_manifest_info["gid"])
944+
)
945+
for branch_name, manifest_info in manifests.items():
934946
branch = self._branches[branch_name]
947+
manifest_id = manifest_info if isinstance(manifest_info, str) else manifest_info["gid"]
935948
if not branch.password_required:
936-
manifest = ManifestInfo(state, ManifestID(int(manifest_id)), branch=branch)
949+
manifest = ManifestInfo(
950+
state,
951+
ManifestID(int(manifest_id)),
952+
branch=branch,
953+
size=maybe_get(manifest_info, "size"),
954+
download_size=maybe_get(manifest_info, "download"),
955+
)
937956
else:
938957
encrypted_id = PrivateManifestInfo._get_id(depot, branch)
939958
if encrypted_id is not None:
940959
manifest = PrivateManifestInfo(state, encrypted_id, branch)
941960
else: # fall back to the public version
942961
manifest = ManifestInfo(
943-
state, ManifestID(int(manifests["public"])), branch=self.public_branch
962+
state,
963+
public_id,
964+
branch=self.public_branch,
965+
size=maybe_get(public_manifest_info, "size"),
966+
download_size=maybe_get(public_manifest_info, "download"),
944967
)
945968

946969
depot_ = Depot(

steam/types/manifest.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,16 @@ class Extended(TypedVDFDict, total=False):
5353
homepage: str
5454

5555

56+
class Manifest(TypedVDFDict, total=False):
57+
gid: Required[VDFInt]
58+
size: VDFInt
59+
download: VDFInt
60+
61+
5662
class Depot(TypedVDFDict, total=False):
5763
name: str
5864
config: Required[MultiDict[str]]
59-
manifests: MultiDict[VDFInt] # {branch name: id}
65+
manifests: MultiDict[VDFInt | Manifest] # {branch name: id}
6066
encryptedmanifests: MultiDict[MultiDict[VDFInt]] # {branch name: {encrypted_gid2: VDFInt}}
6167
branches: MultiDict[Branch]
6268
maxsize: VDFInt

0 commit comments

Comments
 (0)