thomasasfk / drs2dd

dance rush stardom chart -> dance dash beat map
13 stars 2 forks source link

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

Closed thomasasfk closed 1 year ago

thomasasfk commented 1 year ago

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 1 year ago
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 1 year ago

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