Add read-only database V2 parser
This commit is contained in:
@@ -10,6 +10,10 @@ SAMPLE_ROOT = Path(__file__).parent
|
||||
SERATO_PATH_PREFIX = "Users/sample-user/OneDrive/Jukebox/"
|
||||
|
||||
|
||||
def database_record(tag: bytes, payload: bytes) -> bytes:
|
||||
return tag + len(payload).to_bytes(4, "big") + payload
|
||||
|
||||
|
||||
def load_manifest() -> dict:
|
||||
return json.loads((SAMPLE_ROOT / "manifest.json").read_text(encoding="utf-8"))
|
||||
|
||||
@@ -51,6 +55,16 @@ def build_sample(output: Optional[Path] = None) -> Path:
|
||||
)
|
||||
(crate_root / output_name).write_bytes(records.encode("utf-16-le"))
|
||||
|
||||
database_records = [
|
||||
database_record(b"vrsn", "2.0/Serato Doctor Fixture".encode("utf-16-be"))
|
||||
]
|
||||
for relative_path in manifest["tracks"]:
|
||||
fields = database_record(
|
||||
b"pfil", f"{SERATO_PATH_PREFIX}{relative_path}".encode("utf-16-be")
|
||||
)
|
||||
database_records.append(database_record(b"otrk", fields))
|
||||
(serato_root / "database V2").write_bytes(b"".join(database_records))
|
||||
|
||||
return root
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user