uplika/uplika-plugin / skills/yt-chapters
yt-chapters
VerifiedWrite YouTube chapters from a transcript, checked against YouTube's chapter rules so they render, and add them to the video. For chapters, timestamps.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.6 KB |
| scripts/chapters.py | script | 5.1 KB |
| tests/test_chapters_ko.py | script | 2.5 KB |
scripts/chapters.py
View on GitHub#!/usr/bin/env python3
"""chapters.py - YouTube chapters from a timestamped transcript.
python3 chapters.py transcript.srt # or .vtt / whisper .json
python3 chapters.py transcript.srt --target 8 --json
Prints a description block you can paste straight under a video. YouTube's own rules, enforced here
rather than assumed: the list must start at 00:00, needs at least three entries, and each chapter
must be at least 10 seconds long. A block that breaks any of those silently does not become
chapters, which is why this checks instead of trusting.
Boundaries come from the gaps - the pauses you actually took between sections - scored by how long
the pause was and how much the vocabulary changes across it. It is a first draft you retitle, not a
summariser.
"""
# Adapted from Jakeschincariol/youtube-agent-skill (MIT) for the Uplika plugin. English behaviour is
# the original. Korean (2026-10-10) is heuristic, NOT calibrated: the original keyword pattern
# [a-z']{4,} reads no Hangul, so a Korean transcript had no vocabulary shift and every title was
# "Section". Korean keywords are Hangul words of two or more syllables with particles attached
# (no morphological analyser), minus common function words. The module docstring above is the
# CLI's usage text, so it stays the original.
import json, os, re, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "yt-edit", "scripts"))
from deadair import load, parse_ts # noqa: E402 (same parser, one implementation)
STOP = set("the a an of for to in on and or is are was were be been with this that it as at by from "
"you your i my we our they them he she but so if then than there here what which who how "
"when where why not no yes do does did just really very like about into over out up down "
"can could will would should have has had get got make made go going went one two".split())
HANGUL = re.compile(r"[가-힣]")
STOP_KO = set("그리고 그래서 그런데 그러니까 그러면 이제 진짜 정말 너무 이렇게 그렇게 저렇게 이거 그거 저거 이건 그건 "
"이게 그게 이런 그런 저런 우리 여러분 제가 저는 그냥 약간 조금 많이 어떻게 있는 하는 있고 하고 합니다 "
"있습니다 없습니다 됩니다 거예요 겁니다 해요 있어요 없어요 돼요 같아요".split())
def keywords(text):
found = {w for w in re.findall(r"[a-z']{4,}", text.lower()) if w not in STOP}
if HANGUL.search(text):
found |= {w for w in re.findall(r"[가-힣]{2,}", text) if w not in STOP_KO}
return found
def mmss(t):
t = int(t); h, m, s = t // 3600, (t % 3600) // 60, t % 60
return f"{h}:{m:02d}:{s:02d}" if h else f"{m}:{s:02d}"
def main():
a = sys.argv[1:]
as_json = "--json" in a; a = [x for x in a if x != "--json"]
target = int(a[a.index("--target") + 1]) if "--target" in a else 7
a = [x for x in a if not x.startswith("--") and not x.isdigit()]
if not a or not os.path.exists(a[0]): print(__doc__); sys.exit(1)
cues = load(a[0])
if len(cues) < 6: print("too few cues to chapter"); sys.exit(1)
dur = cues[-1][1]
cand = []
for i in range(1, len(cues)):
gap = cues[i][0] - cues[i - 1][1]
before = " ".join(c[2] for c in cues[max(0, i - 12):i])
after = " ".join(c[2] for c in cues[i:i + 12])
kb, ka = keywords(before), keywords(after)
shift = 1 - (len(kb & ka) / len(kb | ka)) if (kb | ka) else 0
cand.append((gap * 1.6 + shift * 3.2, cues[i][0], i))
cand.sort(reverse=True)
picked, MIN = [0.0], 10.0
for _, t, i in cand:
if len(picked) >= target: break
if all(abs(t - p) >= MIN for p in picked) and dur - t >= MIN:
picked.append(t)
picked.sort()
chapters = []
for n, t in enumerate(picked):
end = picked[n + 1] if n + 1 < len(picked) else dur
text = " ".join(c[2] for c in cues if c[0] >= t and c[1] <= end)
kw = [w for w in keywords(text)]
kw.sort(key=lambda w: -text.lower().count(w))
if HANGUL.search(text): kw.sort(key=lambda w: (-text.lower().count(w), w)) # same order on every run
title = " ".join(w.capitalize() for w in kw[:3]) or "Section"
chapters.append({"start": round(t, 2), "label": mmss(t), "draft_title": title,
"seconds": round(end - t, 2)})
ok = len(chapters) >= 3 and chapters[0]["start"] == 0 and all(c["seconds"] >= MIN for c in chapters)
ko = any(HANGUL.search(c[2]) for c in cues)
if as_json:
out = {"valid": ok, "chapters": chapters}
if ko: out.update({"language": "ko", "calibration": "none"})
print(json.dumps(out, indent=1)); return
print()
for c in chapters: print(f" {c['label']} {c['draft_title']}")
print(f"\n {len(chapters)} chapters"
f"{'' if ok else ' -- INVALID: YouTube needs 3+, a 00:00 first entry and 10s minimum each'}")
if ko: print(" Korean: heuristic, not calibrated (the topic words are whole words with their particles).")
print(" Retitle every line before pasting. These are the topic words, not your words.\n")
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |