A Python library for extracting MPQ (MoPaQ) files.
Likely abandoned. No release or commit for years (last release over 12 years ago).
pip install mpyqmpyq
mpyq is a Python library for reading MPQ (MoPaQ) archives used in many of Blizzard's games. It was originally developed for data mining Starcraft II replay files.
In addition to being a library, mpyq also has a command line interface that exposes some of the library's core functionality such as extracting archives.
At this early stage in development only files compressed with DEFLATE or bzip2 are uncompressed. This means that this library can not be used to extract most big game asset archives that Blizzard's games use. More compression formats will be supported in the future.
Also, as mpyq is so far pure Python code, it might be unfeasible to try to extract very large MPQ archives, even if all the compression methods used inside the archive were supported.
Note that listing files inside an archive does not require full extraction. You can safely take a peek inside any MPQ archive with this library.
Installation
A stable version of mpyq is available from PyPI and can be installed with
either easy_install or pip.
$ easy_install mpyq
$ pip install mpyq
mpyq can be installed manually with the included setup.py script.
$ python setup.py install
Running this command will install mpyq both as a library and a stand-alone script that can be run from anywhere, provided that you have added Python's bin directory to your PATH environment variable.
Alternative way to install mpyq is to clone this git repository somewhere on your filesystem and then either adjust your PYTHONPATH environment variable to point to the directory that contains the repository or create a symbolic link to your Python's site-packages directory pointing at the repository.
Note that the command line interface part of mpyq uses the argparse module, which was included into Python's standard library in version 2.7. If you didn't install mpyq from PyPI and you wish to use the command line interface part with Python 2.6, you should install argparse from PyPI manually.
Usage
As a library
>>> from mpyq import MPQArchive
>>> archive = MPQArchive('game.SC2Replay')
Now you have a MPQArchive object of the file you opened. One common thing to do now is to extract the files from the archive.
>>> files = archive.extract()
This will extract and return the archive's contents in memory. Be advised that you might not want to do this with multi-gigabyte MPQ files from World of Warcraft, for example.
Files inside the archive can be also extracted and written to disk.
>>> archive.extract_to_disk()