Lightweight CLI for two fast workflows built on top of yt-dlp:
- search YouTube with the native YouTube search engine and return the top K results;
- extract a clean transcript from a video's subtitles or automatic captions.
The project uses the Python standard library only and calls yt-dlp through subprocesses to stay simple and fast.
- Python 3.11+
yt-dlpavailable onPATH
python3 -m pip install -e .On macOS/Homebrew, the system pip may be blocked by PEP 668. The recommended development setup is:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .Once the environment is activated, youtube-cli is available from any directory, not only from the project root.
If you want a globally available command without activating a virtual environment:
brew install pipx
pipx install --editable /Users/mohamed/Documents/indé/portfolio/youtube-cliFast search for the first 5 results:
youtube-cli search "python tutorial" -k 5JSON output:
youtube-cli search "python tutorial" -k 5 --format jsonSearch with richer metadata, but slower:
youtube-cli search "python tutorial" -k 5 --full-metadataTranscript from a video ID:
youtube-cli transcript K5KVEU3aaeQTranscript with a preferred language:
youtube-cli transcript K5KVEU3aaeQ --lang en-orig
youtube-cli transcript K5KVEU3aaeQ --lang frBy default, the output removes common speech fillers such as um, uh, and erm.
If you want to keep a more literal transcript:
youtube-cli transcript K5KVEU3aaeQ --keep-fillersTranscript as JSON:
youtube-cli transcript K5KVEU3aaeQ --format jsonWithout an editable install, you can also run the CLI directly from the repository root:
PYTHONPATH=src python3 -m youtube_cli search "python tutorial" -k 5
PYTHONPATH=src python3 -m youtube_cli transcript K5KVEU3aaeQsearchusesytsearchK:and--flat-playlistby default to minimize latency.transcriptfirst reads the video JSON to choose a single subtitle language, then downloads only the targeted.vttfile.- Cleaning removes VTT/HTML tags, simple non-speech blocks such as
[Music], common speech fillers such asumanduh, and repeated fragments caused by auto-generated captions.
Run the tests:
PYTHONPATH=src python3 -m unittest discover -s testsPerformance measurements and latency budget:
Real output examples: