CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

gamussa/reels-producer-skill

Write talking-head scripts and produce Instagram reels and YouTube shorts

1.07x
Quality

96%

Does it follow best practices?

Impact

98%

1.07x

Average score across 8 eval scenarios

SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

shorts_from_long.pyskills/reel-builder/scripts/

#!/usr/bin/env python3
"""Find candidate shorts inside a long recording — the timing half of
repurposing, never the judgment half.

A talk, interview or long YouTube video holds several standalone shorts. Which
ones stand alone, keep the speaker's meaning and land a payoff is editorial
judgment (references/long-form.md). What a script CAN do reliably:

  - group the transcript into sentences, and offer windows that start and end
    on sentence boundaries within --min/--max seconds (one per starting
    sentence: the shortest that reaches --min)
  - flag, from fixed word lists, two risks the reader must then check:
      opens_mid_thought   the first word leans on what came before ("so",
                          "this", "but", "it" ...) — a viewer meets it cold
      qualified_after     the NEXT sentence opens with a qualifier ("but",
                          "however", "unless" ...) — ending here can drop the
                          condition that made the claim true

Flags are prompts to read the text, not verdicts. The output is meant to be
read, picked from, and turned into one project per short with its own brief
and selects.

Exit codes: 0 candidates written, 1 none fit / unreadable input. JSON file
plus a readable list on stdout.

Usage:
  shorts_from_long.py talk.words.json --out plan/candidates.json --min 25 --max 75
"""

import argparse
import json
import re
import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parent))
from gen_captions import load_words  # noqa: E402
from trim_words import sentence_groups  # noqa: E402

DANGLING = {
    "and",
    "but",
    "so",
    "because",
    "which",
    "that",
    "this",
    "these",
    "those",
    "it",
    "its",
    "they",
    "them",
    "he",
    "she",
    "also",
    "then",
    "or",
    "there",
    "same",
    "another",
    "other",
}
QUALIFIERS = {
    "but",
    "however",
    "although",
    "though",
    "except",
    "unless",
    "only",
    "yet",
    "still",
    "otherwise",
}
MIN_S, MAX_S = 20.0, 90.0


def first_word(text):
    m = re.match(r"\W*([A-Za-z']+)", text)
    return m.group(1).lower() if m else ""


def candidates(words, min_s=MIN_S, max_s=MAX_S):
    groups = sentence_groups(words)
    spans = [
        (
            float(words[g[0]]["start"]),
            float(words[g[-1]]["end"]),
            " ".join(words[i]["text"] for i in g).strip(),
        )
        for g in groups
    ]
    out = []
    for i in range(len(spans)):
        start = spans[i][0]
        for j in range(i, len(spans)):
            dur = spans[j][1] - start
            if dur > max_s:
                break
            if dur >= min_s:
                text = " ".join(s[2] for s in spans[i : j + 1])
                flags = []
                if first_word(text) in DANGLING:
                    flags.append("opens_mid_thought")
                if j + 1 < len(spans) and first_word(spans[j + 1][2]) in QUALIFIERS:
                    flags.append("qualified_after")
                out.append(
                    {
                        "start": round(start, 3),
                        "end": round(spans[j][1], 3),
                        "duration": round(dur, 2),
                        "sentences": j - i + 1,
                        "text": text,
                        "flags": flags,
                    }
                )
                break
    return out


def main():
    ap = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    ap.add_argument("words_json")
    ap.add_argument("--out", default="plan/candidates.json")
    ap.add_argument(
        "--min", type=float, default=MIN_S, help=f"shortest window, s (default {MIN_S:g})"
    )
    ap.add_argument(
        "--max", type=float, default=MAX_S, help=f"longest window, s (default {MAX_S:g})"
    )
    a = ap.parse_args()
    if a.min <= 0 or a.max <= a.min:
        sys.exit("--min must be > 0 and below --max")
    found = candidates(load_words(a.words_json), a.min, a.max)
    if not found:
        sys.exit(f"No sentence-aligned window between {a.min:g}s and {a.max:g}s — widen the range.")
    out = Path(a.out)
    out.parent.mkdir(parents=True, exist_ok=True)
    out.write_text(
        json.dumps(
            {"source": a.words_json, "min": a.min, "max": a.max, "candidates": found}, indent=2
        )
    )
    clean = sum(1 for c in found if not c["flags"])
    print(f"{len(found)} candidate window(s), {clean} without flags -> {out}\n")
    for c in found:
        mark = ",".join(c["flags"]) or "-"
        print(
            f"  {c['start']:8.2f}-{c['end']:<8.2f} {c['duration']:5.1f}s  [{mark}]  "
            f"{c['text'][:90]}"
        )
    print(
        "\nRead each candidate in full. Keep one only if it stands alone, keeps the "
        "speaker's qualifications, and ends on a payoff — references/long-form.md."
    )


if __name__ == "__main__":
    main()

skills

tile.json