Skip to content

Commit abf65ab

Browse files
utils: update appinfo for new format
Close #418
1 parent eb3bf31 commit abf65ab

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

steam/utils/appcache.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
>>> header, apps = parse_appinfo(open('/d/Steam/appcache/appinfo.vdf', 'rb'))
99
>>> header
10-
{'magic': b"'DV\\x07", 'universe': 1}
10+
{'magic': b"(DV\\x07", 'universe': 1}
1111
>>> next(apps)
1212
{'appid': 5,
1313
'size': 79,
@@ -16,6 +16,7 @@
1616
'access_token': 0,
1717
'sha1': b'\\x87\\xfaCg\\x85\\x80\\r\\xb4\\x90Im\\xdc}\\xb4\\x81\\xeeQ\\x8b\\x825',
1818
'change_number': 4603827,
19+
'data_sha1': b'\\x87\\xfaCg\\x85\\x80\\r\\xb4\\x90Im\\xdc}\\xb4\\x81\\xeeQ\\x8b\\x825',
1920
'data': {'appinfo': {'appid': 5, 'public_only': 1}}}
2021
2122
>>> header, pkgs = parse_packageinfo(open('/d/Steam/appcache/packageinfo.vdf', 'rb'))
@@ -52,7 +53,7 @@ def parse_appinfo(fp):
5253
:return: (header, apps iterator)
5354
"""
5455
# format:
55-
# uint32 - MAGIC: "'DV\x07"
56+
# uint32 - MAGIC: "'DV\x07" or "(DV\x07"
5657
# uint32 - UNIVERSE: 1
5758
# ---- repeated app sections ----
5859
# uint32 - AppID
@@ -62,12 +63,13 @@ def parse_appinfo(fp):
6263
# uint64 - accessToken
6364
# 20bytes - SHA1
6465
# uint32 - changeNumber
66+
# 20bytes - binary_vdf SHA1 (added in "(DV\x07"
6567
# variable - binary_vdf
6668
# ---- end of section ---------
6769
# uint32 - EOF: 0
6870

6971
magic = fp.read(4)
70-
if magic != b"'DV\x07":
72+
if magic not in (b"'DV\x07", b"(DV\x07"):
7173
raise SyntaxError("Invalid magic, got %s" % repr(magic))
7274

7375
universe = uint32.unpack(fp.read(4))[0]
@@ -87,9 +89,13 @@ def apps_iter():
8789
'access_token': uint64.unpack(fp.read(8))[0],
8890
'sha1': fp.read(20),
8991
'change_number': uint32.unpack(fp.read(4))[0],
90-
'data': binary_load(fp),
9192
}
9293

94+
if magic == b"(DV\x07":
95+
app['data_sha1'] = fp.read(20)
96+
97+
app['data'] = binary_load(fp)
98+
9399
yield app
94100

95101

0 commit comments

Comments
 (0)