Skip to content

Python Interfaces

SydMontague edited this page Apr 7, 2021 · 3 revisions

To use the Python interface place the DSCSTools.pyd (renamed .dll) or DSCSTools.so in a folder where your program finds it as a viable module (such as the root folder).

If you plan to use the pre-build binary you will have to use Python 3.8. Other versions require the library to be recompiled.

Using import DSCSTools gives you access to the following functions:

MDB1/MVGL (Main Archives)

void extractMDB1(sourceArchive, targetPath)

Extracts a MDB1 archive given by sourceArchive and extracts it into targetPath or throws an error if something went wrong. The encryption status of the archive doesn't matter.

void extractMDB1File(sourceArchive, targetPath, filePath)

Extracts a file with the internal path filePath from a MDB1 archive given by sourceArchive into targetPath. The encryption status of the archive doesn't matter.

ArchiveInfo getArchiveInfo(sourceArchive)

Returns the ArchiveInfo of an MDB1 archive given by sourceArchive. See the ArchiveInfo object docs down below. The encryption status of the archive doesn't matter.

void packMDB1(sourcePath, targetArchive, compressionMode = normal, useStdout = false)

Packs a folder given by sourcePath into an encrypted MDB1 archive saved at targetArchive. You can optionally set the compression mode and whether to print progress reports to stdout. Valid values for compressMode are:

  • DSCSTools.CompressMode.none -> no compression at all
  • DSCSTools.CompressMode.normal -> regular compression
  • DSCSTools.CompressMode.advanced -> regular compression with duplicate detection

void crypt(sourceFile, targetFile)

Performs synchronous en-/decryption of the given sourceFile and saves it into targetFile.

MBE Archives (Game Data)

void extractMBE(sourcePath, targetPath)

Extracts the MBE file or folder containing them given by sourcePath into targetPath.
The structures folder must be at the root of your execution context for this to work.

void packMBE(sourcePath, targetFile)

Packs the given MBE folder given by sourcePath into an MBE saved into targetFile.
The structures folder must be at the root of your execution context for this to work.

AFS2 Archives (Audio Files)

void extractAFS2(sourceFile, targetPath)

Extracts the AFS2 archive given by sourceFile into targetPath.

void packAFS2(sourcePath, targetFile)

Packs the folder given by sourcePath into an AFS2 archive saved into targetFile.

PC Savefiles

void encryptSaveFile(sourceFile, targetFile)

Encrypts the PC save file given by sourceFile into targetFile.

void decryptSaveFile(sourceFile, targetFile)

Decrypts the PC save file given by sourceFile into targetFile.

Structures

Everything given are properties that can be accessed normally from the returned object.

DSCSTools.ArchiveInfo

  • ArchiveStatus -> DSCSTools.ArchiveStatus | gives the status of the archive, should be checked to make sure it's valid
  • FileCount -> Number of files in the archive
  • DataStart -> Starting offset of the actual file data
  • Files -> List of FileInfo's of the files contained in the archive

DSCSTools.FileInfo

  • FileName -> the path of the file, to be used with extractMDB1File calls
  • DataOffset -> the offset of the file data in the archive
  • DataSize -> the size of the file after compression
  • DataCompressedSize -> the size of the file within the archive, if this equals DataSize it's not encrypted