YouTube subtitles -> Russian summary -> Q&A chat (via OpenRouter).
yousum is a config-first CLI. You put all runtime options in parameters.json, then run:
yousum "https://www.youtube.com/watch?v=VIDEO_ID"- What It Does
- Features
- How It Works
- Requirements
- Install
- Configure
- Run
- Configuration Reference
- YouTube Cookies / Authentication
- Cache And Outputs
- Chat
- Environment Variables
- Troubleshooting
- Security
- Development
- License
Given a YouTube URL, yousum:
- Extracts subtitles (human-made preferred, auto-captions as fallback) using
yt-dlp. - Normalizes subtitles into a plain transcript and caches it locally.
- Generates a Russian summary with a configurable target word count using an LLM via OpenRouter.
- Opens an interactive terminal chat for Q&A grounded in the transcript.
- Subtitles extraction via
yt-dlp- manual subtitles preferred, auto captions as fallback
- formats supported:
vtt,srt,ttml,srv1/2/3,json3
- Russian summary (word count configurable)
- chunking + two-pass summarization for long transcripts
- best-effort target word count
- Q&A chat grounded in subtitles
- if the answer is not present in the transcript, the assistant should say so
- chat commands:
/summary,/exit - user input is color-highlighted in TTY terminals
- Caching
- transcript cache:
.yousum_cache/<video_id>/... - summaries:
outputs/<video_id>/summary_ru_<words>.txt
- transcript cache:
- Minimal CLI
- no long flag lists: configure once in
parameters.json, then runyousum <url>
- no long flag lists: configure once in
yt-dlpextracts video metadata and subtitle tracks.yousumpicks a subtitle language fromprefer_langs(defaultru, thenen), with source priority manual -> auto.- Subtitles are downloaded, parsed, and normalized into a single transcript.
- The transcript is summarized via OpenRouter Chat Completions.
- Chat mode retrieves a few relevant transcript chunks and asks the LLM to answer based on them.
- Python 3.10+
- Internet access
- OpenRouter API key
Notes:
- YouTube frequently changes access rules. If
yt-dlpreports bot checks or JS challenges, you may need cookies and/or a JavaScript runtime (see Troubleshooting).
Recommended: create a virtual environment and install from this repo.
python -m venv .venv
./.venv/bin/python -m ensurepip --upgrade
./.venv/bin/python -m pip install -U pip
./.venv/bin/python -m pip install -r requirements.txtVerify:
./.venv/bin/yousum --help
./.venv/bin/python -m yousum --helpKeep your key out of shell history and do not share it publicly.
- Copy
.env.exampleto.env - Set your key:
OPENROUTER_API_KEY="YOUR_OPENROUTER_API_KEY"Keep .env private.
Edit parameters.json (or parametrers.json) in the project root.
Safe default example (no secrets):
{
"model": "openrouter/free",
"summary_words": 250,
"temperature": 0.2,
"prefer_langs": ["ru", "en"],
"cache_dir": ".yousum_cache",
"out_dir": "outputs",
"refresh": false,
"cookies": null,
"cookies_from_browser": null
}Tip: if you do not want to keep personal settings (cookies, custom paths) in the main parameters.json, create
parameters.local.json and run with YOUSUM_PARAMETERS_FILE=parameters.local.json.
Shortest (summary + chat):
./.venv/bin/yousum "https://www.youtube.com/watch?v=VIDEO_ID"Same thing via python -m:
./.venv/bin/python -m yousum "https://www.youtube.com/watch?v=VIDEO_ID"Explicit commands:
./.venv/bin/yousum summarize "https://www.youtube.com/watch?v=VIDEO_ID"
./.venv/bin/yousum chat "https://www.youtube.com/watch?v=VIDEO_ID"
./.venv/bin/yousum run "https://www.youtube.com/watch?v=VIDEO_ID"Caching behavior:
- If a summary file already exists in
outputs/andrefresh=false,summarize/chatwill reuse it. - Set
"refresh": trueinparameters.jsonto force re-download and regeneration.
parameters.json keys:
model(string): OpenRouter model name, e.g.openrouter/freesummary_words(int): target Russian summary word count (default 250)temperature(number): LLM temperature (0..2, default 0.2)prefer_langs(array of strings OR comma-separated string): preferred subtitle languages, e.g.["ru","en"]or"ru,en"cache_dir(string): transcript cache dir (default.yousum_cache)out_dir(string): output dir for summaries (defaultoutputs)refresh(bool): force re-download and regeneration (defaultfalse)cookies(string|null): path tocookies.txt(Netscape format) for YouTube authcookies_from_browser(string|null): browser cookies loader (yt-dlp format)
Examples:
Use cookies from Brave profile:
{ "cookies_from_browser": "brave:Default" }Use an explicit profile path (supports ~ and environment variables like $HOME):
{
"cookies_from_browser": "brave:$HOME/.config/BraveSoftware/Brave-Browser/Default"
}Use exported cookies file:
{ "cookies": "~/Downloads/cookies.txt" }YouTube may block anonymous requests with messages like:
Sign in to confirm you're not a bot
In that case, configure cookies.
Supported browsers:
brave,chrome,chromium,edge,firefox,opera,safari,vivaldi,whaleyandex(Linux, Chromium-based; supported via profile discovery under~/.config/yandex-browser)
Format (same as yt-dlp): BROWSER[+KEYRING][:PROFILE][::CONTAINER]
Examples:
"brave:Default""chrome:Default""edge:Default""firefox:default""opera"(Opera typically does not use profile names)"safari"(macOS)
Linux note:
cookies_from_browsermay require keyring access.- The project includes
secretstorageon Linux, but your desktop session still needs a working keyring. - If keyring access is unavailable (headless/sandboxed), use exported
cookies.txtinstead.
Export YouTube cookies to Netscape format and point cookies to the file.
Treat exported cookies as secrets and do not share them publicly.
Default layout:
.yousum_cache/<video_id>/transcript.txt(normalized text)meta.json(metadata)- raw subtitle file (e.g.
*.vtt)
outputs/<video_id>/summary_ru_<words>.txt
Cleanup:
rm -rf .yousum_cache outputsThe chat starts automatically in run mode.
Commands:
/summaryprint the saved summary/exitexit
Chat policy:
- answers should be based on subtitles context only
- if it is not mentioned in the transcript, the assistant should say so
OPENROUTER_API_KEY(required)OPENROUTER_BASE_URL(optional, defaulthttps://openrouter.ai/api/v1)OPENROUTER_APP_NAME(optional, sent asX-Title)OPENROUTER_REFERRER(optional, sent asHTTP-Referer)YOUSUM_PARAMETERS_FILE(optional, path to an alternative parameters JSON)
Error:
Missing OpenRouter API key
Fix:
- set
OPENROUTER_API_KEYvia.env(recommended), orexport OPENROUTER_API_KEY="..."
Error:
Sign in to confirm you're not a bot
Fix:
- configure
cookies_from_browserorcookiesinparameters.json
Error:
could not find <browser> cookies database ...
Fix:
- Ensure the browser/profile exists.
- In sandboxed terminals (Flatpak/Snap), set an explicit profile path, e.g.:
{ "cookies_from_browser": "brave:$HOME/.config/BraveSoftware/Brave-Browser/Default" }- If it still fails, use exported
cookies.txt.
Symptoms:
secretstorage not available- cookies cannot be decrypted
Fix:
- ensure
secretstorageis installed in your venv - ensure you have a working desktop keyring session
- otherwise use exported
cookies.txt
Error:
No subtitles found (manual or auto)
Fix:
- try another language in
prefer_langs - some videos have no subtitles at all
- if extraction is failing due to YouTube restrictions, use cookies
Symptoms:
- warnings mentioning
EJS Requested format is not available(even though you only need subtitles)
Notes:
yousumsetsignore_no_formats_errorto keep working when only subtitles are available.
Fixes to try:
- update
yt-dlp:./.venv/bin/python -m pip install -U yt-dlp - install a supported JS runtime (
nodeordeno) and follow yt-dlp EJS docs - use cookies (often enough)
Do not publish/share:
.env(OpenRouter key)cookies*.txt(exported cookies).venv/,.yousum_cache/,outputs/
Secret scan before sharing:
rg -n --hidden \
--glob '!.venv/**' \
--glob '!.yousum_cache/**' \
--glob '!outputs/**' \
-- "OPENROUTER_API_KEY=|cookies(\\.txt)?|BEGIN (RSA|OPENSSH) PRIVATE KEY" .If you accidentally leaked a key/cookies: revoke/rotate them immediately.
Install with dev extras:
./.venv/bin/python -m pip install -e ".[dev]"Run tests:
./.venv/bin/python -m pytest -qMIT. See LICENSE.