Posted on ::

Multi-disc PS1 games are easy to lose track of. psx-tools is a set of small Python scripts for working with PSX ROMs.

  • detect-title reads the Title ID from a disc image.
  • lookup-disc finds the game by Title ID using SerialStation.
  • m3u_gen writes .m3u playlists for every disc set in a folder.

Finding the Title ID

The scanner skips the first 32 KiB of the image, then reads the rest in 4 KiB chunks until a regex matches a Title ID such as SLUS_012.51:

def get_psx_id(file_path: str) -> str | None:
    try:
        with open(file_path, "rb") as fin:
            _ = fin.seek(32768)  # Skip the first 32768 bytes
            while buffer := fin.read(4096):
                buffered = buffer.decode("ISO-8859-1")
                matches = title_re.search(buffered)
                if matches:
                    return matches.group(0)
    except Exception:
        pass

Source on GitHub

Table of Contents