Transform raw YouTube subtitles into publication-grade bilingual study guides (A4 PDF & Markdown notes) โ Engineered for language learners, developers, and autonomous AI agents
English ยท ็ฎไฝไธญๆ ยท LINUX DO Community ยท Agent Guidelines ยท Contributing ยท License: MIT
- ๐งฉ ASR De-duplication & Sentence Boundary Reconstruction:
Strips rolling word repetitions and inline
<c>word tags from YouTube auto-generated captions. Reconstructs fragmented lines into complete sentences using punctuation boundaries (.,!,?), grouping them into coherent paragraphs (~50 words each). - ๐ Whole-Word Typography (Zero Hyphen Fragmentation):
Avoids forced justification and CSS hyphen chopping (
hyphens: auto) that mutilates complex vocabulary. Enforces strict natural left-aligned typography (text-align: left; hyphens: none; word-break: normal;), guaranteeing every foreign word stays whole and readable in PDF. - โฑ๏ธ Timestamp Anchor Indexing:
Preserves precise source video timestamp anchors (
[MM:SS]) for every reconstructed paragraph, allowing instant playback verification and pronunciation review directly in YouTube. - ๐ International Phonetic Alphabet (IPA) & Lexical Collocations: Extracts 15โ25 high-leverage idioms, technical terms, and vocabulary items from the context, complete with IPA phonetic transcriptions, part of speech, concise translations, and in-situ video collocations.
- ๐งน Zero-Clutter Delivery Guarantee:
Temporary HTML layout targets are automatically purged after PDF compilation. Intermediate working JSON files are safely archived to
~/.sub2study/cache/, ensuring the target output folder strictly contains only the final deliverables ([Title].pdfand[Title].md). - ๐ค Autonomous AI Agent Ready:
Designed to work natively with Claude Code, OpenAI Codex, Cursor, and Google Antigravity (AGY) via built-in guidelines (
SKILL.md,CLAUDE.md,AGENTS.md). - ๐ฆ Dual-Format Asset Generation:
- A4 Vector PDF (
.pdf): Compiled via Chromium headless rendering engine with native multi-language font support, ideal for iPad annotation and printing; - Structured Markdown (
.md): GitHub-flavored Markdown formatted for immediate import into Obsidian, Notion, or Logseq.
- A4 Vector PDF (
flowchart LR
A["YouTube URL / Local Subtitles"] --> B["sub2study Fetch & Session Management"]
B --> C["ASR Text Cleaning & De-duplication"]
C --> D["Punctuation Matching & Paragraph Chunking"]
D --> E["AI Proofreading & Contextual Translation"]
E --> F["IPA Vocabulary & Collocation Extraction"]
F --> G["Vector Publication PDF (Chrome Headless)"]
F --> H["Obsidian / Notion Markdown Notes"]
| Region | Styling Specifications | Functional Intent |
|---|---|---|
| Card Header | Paragraph index + [00:01:25] monospace badge |
Allows direct cross-referencing with video audio |
| Source Text | 14px dark slate ยท text-align: left ยท Line-height 1.65 |
Prevents forced hyphen cutting on specialized terms |
| Translation | 13px blue-gray panel ยท 3.5px accent left border | Contextualized translation with domain terminology alignment |
| # | Word / Expression (with IPA) | POS | Definition | Contextual Collocation from Video |
|---|---|---|---|---|
| 1 | equity /หekwษชti/ | n. | Company stock / equity assets | The stock, or companies call it equity |
| 2 | RSUs /หษหr es หjuหz/ | n. | Restricted Stock Units | The most common one is RSUs that tech companies give |
| 3 | vesting schedule | n. | Stock vesting schedule | Vesting determines the frequency with which stock is released |
| 4 | sign-on bonus | n. | Sign-on / hiring bonus | Sign-on bonus is a one-time payment |
- Python 3.9+
- yt-dlp:
brew install yt-dlp(macOS) orpip install yt-dlp - Chrome / Edge / Chromium: Any desktop Chromium browser for headless PDF compilation
git clone https://github.com/itsdangding/sub2study.git
cd sub2study
chmod +x install.sh && ./install.shThe installer configures the editable Python CLI and creates a symlink in
~/.local/bin/sub2study.
sub2study is a modular Python CLI that any terminal-capable AI Agent can invoke directly:
- Claude Code: Native support via
skill/CLAUDE.md. - Cursor / OpenAI Codex: Guided via
skill/AGENTS.md. - Google Antigravity (AGY): Registered globally via
skill/SKILL.md.
Simply send the video URL in your Agent chat:
"Use sub2study to turn this video into a bilingual study guide: https://www.youtube.com/watch?v=vJwoB34Tv2U"
The Agent executes the end-to-end pipeline:
- Downloads and cleans subtitles into coherent paragraphs;
- Proofreads and translates contextually;
- Extracts vocabulary with IPA transcriptions;
- Compiles the PDF and Markdown, automatically cleaning up intermediate files.
sub2study extract "https://www.youtube.com/watch?v=vJwoB34Tv2U" -o ./output --lang autoOptions:
url: YouTube video URL or path to local subtitle file (--vtt);-o, --output-dir: Output directory (default: current directory);--lang: Subtitle language code (default:autoto detect original audio);--min-words: Minimum word threshold per paragraph (default:45);--keep-vtt: Retain raw.vttfile in output directory (default:False).
Quality Standard: Strictly adhere to 100% full translation (Sentence-by-Sentence Integrity). Never compress narrative lectures into bullet summaries. Chinese char count should be
$\ge 1.5\times$ English word count.
Data structure:
{
"paragraphs": [
{ "timestamp": "00:00:00", "ru": "English source text...", "zh": "ไธญๆ่ฏๆ..." }
],
"vocabulary": [
{ "word": "equity", "accent": "/หekwษชti/", "pos": "n.", "meaning": "ๅ
ฌๅธ่กๆ", "collocation": "companies call it equity" }
]
}sub2study render ./output/bilingual_result.json \
-o ./output \
--title "How Tech Salaries Actually Work" \
--video-url "https://www.youtube.com/watch?v=vJwoB34Tv2U" \
--speaker "Ex-Spotify Analyst" \
--source-lang enOptions:
--keep-html: Preserve intermediate HTML layout file (default: auto-removed);--no-clean: Prevent archiving intermediate JSON files (default: auto-archived to cache).
Upon completion, the target directory strictly contains only the final deliverables:
output/
โโโ How_Tech_Salaries_Actually_Work_Bilingual_Study_Guide.pdf # Publication-grade A4 PDF
โโโ How_Tech_Salaries_Actually_Work_Bilingual_Study_Guide.md # Structured Markdown study notes
This project acknowledges and is shared with the LINUX DO community.
- Community portal: https://linux.do
- Warmly welcoming LINUX DO community members to connect and share.
Contributions, issues, and feature requests are welcome! Please check the CONTRIBUTING.md guide for guidelines on PRs and local development.
Distributed under the MIT License. Contributions, issues, and feature requests are welcome!