rpgmaker_mv_decoder package

Submodules

rpgmaker_mv_decoder.exceptions module

Custom Exception Types

exception rpgmaker_mv_decoder.exceptions.Error(message: str)[source]

Bases: Exception

Base class for exceptions in this module.

Attributes:

  • message: Explanation of the error

exception rpgmaker_mv_decoder.exceptions.FileFormatError(expression: str, message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.Error

Exception raised for errors in the input. Based on Error class

Attributes:

  • expression: Input expression in which the error occurred

  • message: Explanation of the error

exception rpgmaker_mv_decoder.exceptions.NoValidFilesFound(message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.Error

Exception raised when no files are found. Based on Error class

Attributes:

  • message: Explanation of the error

exception rpgmaker_mv_decoder.exceptions.PNGHeaderError(expression: str, message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.FileFormatError

Exception raised for PNG images that when the IHDR section doesn’t checksum correctly.

Attributes:

  • expression – Input expression in which the error occurred

  • message – Explanation of the error

exception rpgmaker_mv_decoder.exceptions.RPGMakerHeaderError(expression: str, message: str)[source]

Bases: rpgmaker_mv_decoder.exceptions.FileFormatError

Exception raised for files missing the RPGMaker MV header.

Attributes:

  • expression – Input expression in which the error occurred

  • message – Explanation of the error

rpgmaker_mv_decoder.utils module

Utility functions

rpgmaker_mv_decoder.utils.decode_files(src: str, dst: str, key: str, detect_type: bool, pb_cb: Optional[Callable[[tkinter.ttk.Progressbar], bool]] = None) None[source]

decode_files Decodes the files

Finds all rpgmvp and rpgmvo files and decodes them

Args:

  • src (str): Source directory to search

  • dst (str): Destination directory for output

  • key (str): Key to use for decoding

  • detect_type (bool): If file extensions should be detected from the file contents

  • pb_cb (Callable[[click._termui_impl.Progressbar], bool], optional): Callback to display current progress. Call with None when bar is complete. Returns True if the user has canceled the operation. Defaults to None.

rpgmaker_mv_decoder.utils.encode_files(src: str, dst: str, key: str, pb_cb: Optional[Callable[[tkinter.ttk.Progressbar], bool]] = None) None[source]

encode_files Encodes the files

Finds all images and audio files and encodes them

Args:

  • src (str): Source directory to search

  • dst (str): Destination directory for output

  • key (str): Key to use for encoding

  • pb_cb (Callable[[click._termui_impl.Progressbar], bool], optional): Callback to display current progress. Call with None when bar is complete. Returns True if the user has canceled the operation. Defaults to None.

rpgmaker_mv_decoder.utils.encode_header(file_header: bytes, key: str) bytes[source]

encode_header Encode a file with a key

Takes first 16 bytes and encodes per RPGMaker MV standard

Args:

  • file_header (bytes): 16 bytes

  • key (str): Key to encode with

Returns:

  • bytes: First 32 bytes of the encoded file

rpgmaker_mv_decoder.utils.get_file_ext(data: bytes) str[source]

get_file_ext Returns a file extension based on the file contents

Uses libmagic to figure out the actual file type and place a proper extension on the file

Args:

  • data (bytes): File data

Raises:

  • FileFormatError: Error if the file type is unknown

Returns:

  • str: Extension for the file

rpgmaker_mv_decoder.utils.guess_at_key(src: pathlib.Path, pb_cb: Optional[Callable[[tkinter.ttk.Progressbar], bool]] = None) str[source]

guess_at_key Check the path for PNG images and return the decoding key

Finds image files under the specified path and looks for a key to decode all the files. This can fail if only a small number (less than 3) of the .rpgmvp files are .png images.

Args:

  • src (Path): Path to search for .rpgmvp files

  • pb_cb (Callable[[click._termui_impl.Progressbar], bool], optional): Callback to display current progress. Call with None when bar is complete. Returns True if the user has canceled the operation. Defaults to None.

Raises:

  • NoValidFilesFound: If no valid PNG images are found

Returns:

  • str: Decoding key

rpgmaker_mv_decoder.utils.read_header_and_decode(file_header: bytes, png_ihdr_data: Optional[bytes] = None, key: str = '89504e470d0a1a0a0000000d49484452') bytes[source]

read_header_and_decode take a RPGMaker header and return the key or the actual file header

Check’s the first 16 bytes for the standard RPGMaker header, then drops them. Takes the next 16 bytes and either calculates the key based on a PNG image, or uses the specify key to decode. If png_ihdr_data is provided, checks that the IHDR section checksums correctly.

Args:

  • file_header (bytes): First 32 bytes from the file, 16 bytes are the RPGMaker header, followed by 16 bytes of the file header

  • png_ihdr_data (bytes): Next 17 bytes for a PNG image to check the IHDR section

  • key (str): Key to use for xor, defaults to a standard PNG header if left unspecified

Raises:

  • RPGMakerHeaderError: The header doesn’t match RPGMaker’s header

  • PNGHeaderError: The PNG’s IHDR section doesn’t checksum correctly

Returns:

  • bytes: If key was None, the key needed for a PNG image header, otherwise the decoded file header.

Module contents

Package for decoding RPGMaker MV/MZ encoded files