Skip to main content

Library for reading/extracting files from VPK

Project description

Latest version released on PyPi MIT License Build status of master branch

VPK is Valve’s file format for storing game assets. This module is able to read the index and individual files.

Install

You can grab the latest release from https://pypi.python.org/pypi/vpk or via pip

pip install vpk

Example usage

The VPK instance is iterable in the standard ways and produces paths to files

import vpk

pak1 = vpk.VPK("/d/Steam/steamapps/common/dota 2 beta/dota/pak01_dir.vpk")

for filepath in pak1:
    print filepath
-------------------------------------------------
sound/half_sec_qd.wav
sound/items/guardian_greaves.wav
sound/items/urn_of_shadows.wav
sound/items/rune_bounty.wav
sound/items/refresher.wav
sound/items/item_mael_lightning_04.wav
sound/items/greevil_whistle.wav
...

Reading a specifc file is done by passing the file path to get_file() method, which returns a VPKFile instance, which acts as a regular file instance. Writting is not possible.

pakfile = pak1.get_file("scripts/emoticons.txt")
print pakfile.read().decode('utf-16le')
-------------------------------------------------
"emoticons"
{
    // An ID of zero is invalid

    "1"
    {
        "image_name" "wink.png"
        "ms_per_frame" "100"
...

Or if you need to extract a file.

pakfile.save("./emoticons.txt")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vpk-0.5.tar.gz (5.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page