forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

seed.sh27 lines, 1.0 KiBHistoryRawDownload
1#!/usr/bin/env bash
2# seed.sh: fill fuzz/corpus/<target>/ from the repo's subtitle fixtures.
3#
4# fixtures/subs/real.srt seeds srt, markup and ir. A WebVTT twin of it (commas become dots, a
5# WEBVTT header goes on) seeds webvtt, markup and ir. Corpus lives under fuzz/corpus, git-ignored.
6set -euo pipefail
7
8FUZZ_DIR=$(cd -- "$(dirname -- "$0")" && pwd)
9ROOT=$(cd -- "$FUZZ_DIR/../../.." && pwd)
10SUBS="$ROOT/fixtures/subs"
11[ -d "$SUBS" ] || { echo "seed.sh: $SUBS missing; run scripts/link-fixtures.sh" >&2; exit 2; }
12
13CORPUS="$FUZZ_DIR/corpus"
14mkdir -p "$CORPUS"/{srt,webvtt,markup,ir}
15
16python3 -I - "$SUBS/real.srt" "$CORPUS" <<'PY'
17import os, sys
18
19srt, corpus = sys.argv[1], sys.argv[2]
20data = open(srt, "rb").read()
21vtt = b"WEBVTT\n\n" + data.replace(b",", b".")
22for target in ("srt", "markup", "ir"):
23 open(os.path.join(corpus, target, "real.srt"), "wb").write(data[:65536])
24for target in ("webvtt", "markup", "ir"):
25 open(os.path.join(corpus, target, "real.vtt"), "wb").write(vtt[:65536])
26print("ec-subs seeds written")
27PY