ValvePython / vdf

📜 Package for working with Valve's text and binary KeyValue format
https://pypi.org/project/vdf/
MIT License
165 stars 30 forks source link

Failure reading binary VDF files #13

Closed barraponto closed 5 years ago

barraponto commented 7 years ago

When I try to read binary files such as appcache/appinfo.vdf or appcache/packageinfo.vdf, I always see the same error:

SyntaxError: Unknown data type at index 5: b"'"

I tried using alt_format=True but it just errors too :/

import vdf
with open('~/.steam/root/appcache/appinfo.vdf', 'rb') as appinfo:
    data = vdf.binary_lods(appinfo.read())
rossengeorgiev commented 7 years ago

The extension says vdf, but it is actually a custom format that has vdf sections for each app. Same for packageinfo.

EhsanKia commented 6 years ago

Any hint on how to parse it then?

EhsanKia commented 6 years ago

Seems like appinfo has a new format recently (january 2017). Parser for it would be highly appreciated.

rossengeorgiev commented 6 years ago

I had a look around and the format is as follows:

appinfo

uint32   - MAGIC: "'DV\x07"
uint32   - UNIVERSE: 1
---- repeated app sections ----
uint32   - AppID
uint32   - size
uint32   - infoState 
uint32   - lastUpdated
uint64   - accessToken
20bytes  - SHA1
uint32   - changeNumber
variable - binary_vdf
---- end of section ---------
uint32   - EOF: 0

packageinfo


uint32   - MAGIC: "'UV\x06"
uint32   - UNIVERSE: 1
---- repeated package sections ----
uint32   - PackageID
20bytes - SHA1
uint32   - changeNumber
variable - binary_vdf
---- end of section ---------
uint32   - EOF: 0xFFFFFFFF
rossengeorgiev commented 4 years ago

Current beta client has updated the format:

packageinfo


uint32   - MAGIC: "'UV\x06"
uint32   - UNIVERSE: 1
---- repeated package sections ----
uint32   - PackageID
20bytes  - SHA1
uint32   - changeNumber
uint64   - token
variable - binary_vdf
---- end of section ---------
uint32   - EOF: 0xFFFFFFFF
xPaw commented 4 years ago

I wrote some C# code to fully parse these files if anyone is interested: https://github.com/SteamDatabase/SteamAppInfo

rossengeorgiev commented 4 years ago

steam package now implements methods for parsing these files in steam.utils.appcache.

https://github.com/ValvePython/steam/issues/179