[Request] Source converter/songs for .s3p containers #3

Closed
opened 2023-09-30 23:34:28 +03:00 by thomasasfk · 2 comments
thomasasfk commented 2023-09-30 23:34:28 +03:00 (Migrated from github.com)

We have beatmaps for these, but no .ogg - we could either source the songs manually and line them up, or find/write some converter for the .s3p files.

シュガーソングとビターステップ (30)
Break Free ft.Zedd (56)
What Do You Mean? (57)
BANG BANG BANG (58)
POP TEAM EPIC (78)
U.S.A. ANOTHER EDITION (298)
We have beatmaps for these, but no `.ogg` - we could either source the songs manually and line them up, or find/write some converter for the `.s3p` files. ``` シュガーソングとビターステップ (30) Break Free ft.Zedd (56) What Do You Mean? (57) BANG BANG BANG (58) POP TEAM EPIC (78) U.S.A. ANOTHER EDITION (298) ```
thomasasfk commented 2023-10-01 00:28:53 +03:00 (Migrated from github.com)
import argparse
import os
import struct


def get_s3v0_header(file):
    header = {}
    magic = file.read(4)
    if magic != b'S3V0':
        raise ValueError("Invalid S3V0 magic")

    header['size'], header['original_size'], header['data_hash'] = struct.unpack("<III", file.read(12))
    file.read(16)  # skip 16 bytes
    return header


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument('--input', help='Input S3P file', required=True)
    args = parser.parse_args()

    with open(args.input, "rb") as infile:
        magic = infile.read(4)
        if magic != b'S3P0':
            raise ValueError("Invalid S3P0 magic")

        num_files = struct.unpack("<I", infile.read(4))[0]
        index = []

        for i in range(num_files):
            offset, size = struct.unpack("<II", infile.read(8))
            index.append((offset, size))

        for i, (offset, size) in enumerate(index):
            infile.seek(offset, 0)
            header = get_s3v0_header(infile)
            data = infile.read(header['original_size'])
            output_file = os.path.join(f"{i}.wma")
            with open(output_file, "wb") as outfile:
                outfile.write(data)

Converter was easy... but the .s3p files I have are only of the intro/preview sections, not the whole songs :/

```python import argparse import os import struct def get_s3v0_header(file): header = {} magic = file.read(4) if magic != b'S3V0': raise ValueError("Invalid S3V0 magic") header['size'], header['original_size'], header['data_hash'] = struct.unpack("<III", file.read(12)) file.read(16) # skip 16 bytes return header if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--input', help='Input S3P file', required=True) args = parser.parse_args() with open(args.input, "rb") as infile: magic = infile.read(4) if magic != b'S3P0': raise ValueError("Invalid S3P0 magic") num_files = struct.unpack("<I", infile.read(4))[0] index = [] for i in range(num_files): offset, size = struct.unpack("<II", infile.read(8)) index.append((offset, size)) for i, (offset, size) in enumerate(index): infile.seek(offset, 0) header = get_s3v0_header(infile) data = infile.read(header['original_size']) output_file = os.path.join(f"{i}.wma") with open(output_file, "wb") as outfile: outfile.write(data) ``` Converter was easy... but the `.s3p` files I have are only of the intro/preview sections, not the whole songs :/
thomasasfk commented 2023-10-01 02:11:43 +03:00 (Migrated from github.com)

Sorted in https://github.com/thomasasfk/drs2dd/pull/4 - found the files elsewhere :)

Sorted in https://github.com/thomasasfk/drs2dd/pull/4 - found the files elsewhere :)
Sign in to join this conversation.