51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""Generate a disposable, synthetic Serato library from the sample manifest."""
|
|
|
|
import argparse
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Optional
|
|
|
|
|
|
SAMPLE_ROOT = Path(__file__).parent
|
|
SERATO_PATH_PREFIX = "Users/djsplice/OneDrive/Jukebox/"
|
|
|
|
|
|
def load_manifest() -> dict:
|
|
return json.loads((SAMPLE_ROOT / "manifest.json").read_text(encoding="utf-8"))
|
|
|
|
|
|
def build_sample(output: Optional[Path] = None) -> Path:
|
|
root = output or SAMPLE_ROOT / "generated"
|
|
manifest = load_manifest()
|
|
music_root = root / "Music"
|
|
crate_root = root / "Serato" / "_Serato_" / "Subcrates"
|
|
crate_root.mkdir(parents=True, exist_ok=True)
|
|
|
|
for relative_path in manifest["tracks"]:
|
|
track_path = music_root / relative_path
|
|
track_path.parent.mkdir(parents=True, exist_ok=True)
|
|
track_path.write_bytes(
|
|
f"Synthetic Serato Doctor fixture: {relative_path}\n".encode("utf-8")
|
|
)
|
|
|
|
for crate in manifest["crates"]:
|
|
records = "".join(
|
|
f"{SERATO_PATH_PREFIX}{relative_path}otrk"
|
|
for relative_path in crate["references"]
|
|
)
|
|
(crate_root / crate["name"]).write_bytes(records.encode("utf-16-le"))
|
|
|
|
return root
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--output", type=Path)
|
|
args = parser.parse_args()
|
|
root = build_sample(args.output)
|
|
print(f"Generated synthetic library: {root}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|