Yt2Cli
A simple command-line (CLI) tool for searching and playing YouTube videos directly from the terminal, without needing to open a browser.
Features
- Search YouTube videos by keyword, with an optional result limit (
--limit=<n>, default 10, max 100) - Results are cached per query, so re-searching the same keyword is instant
- Display search results as formatted video cards (title, ID, channel, views with
K/M/Bsuffix) - Play any video from the list through mpv, falling back to the system's default application if mpv isn't installed
- Any unrecognized command is treated as a search query
- Cross-platform: works on Windows, macOS, and Linux
Requirements
1. Python
Recommended version: Python 3.10 or newer.
2. mpv for video playback (optional)
The app relies on mpv as the default player. If it's not installed, the app will fall back to opening the link with the system's default application.
Installing mpv:
| OS | Command |
|---|---|
| Fedora | sudo dnf install mpv |
| Ubuntu / Debian | sudo apt install mpv |
| macOS (Homebrew) | brew install mpv |
| Windows | Download from mpv.io |
Installation
pip install yt2cli
Usage
yt2cli
This launches an interactive prompt. Type a command and press Enter.
Available Commands
| Command | Description |
|---|---|
search <query> |
Search YouTube videos (--limit=<n> optional) |
list |
Show the currently loaded videos from the last search |
open <id> |
Play a video from the list by its number |
clear |
Clear the terminal screen |
help |
Show a list of available commands |
exit |
Close the app |
Note: Any input that isn't a recognized command is treated as a search query.
Example
Yt2Cli Run: search python tutorial
Now Loading...
********** Search Results For: python tutorial , Limit= 10 **********
──────────────────────────────────────────────────────────────
Python Basics for Beginners
ID : 0
Channel : Programming Academy
Views : 2.34M
──────────────────────────────────────────────────────────────
# The id here is not the id of the video its the video index on the list
Yt2Cli Run: open 0
Project Structure
yt2cli/
├── src/
│ └── yt2cli/
│ ├── __init__.py # App export entry point
│ ├── App.py # Core logic and command handling
│ ├── Backend.py # Search logic (yt-dlp) and result caching
│ ├── Player.py # Video playback (mpv with system fallback)
│ └── cli.py # Interactive REPL entry point
Notes
- The app uses yt-dlp to search and extract video playback URLs.
- Search results are cached per query in memory; playing a video re-resolves the stream URL with yt-dlp.
- Download the Deno Javascript Runtime to get the best Video Quality
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yt2cli-0.1.2.tar.gz.
File metadata
- Download URL: yt2cli-0.1.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/7.1.6-201.fc44.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8d597d2e38c11463203e9adda3eb2037ccad3d2af175a34ac9335cc82125507
|
|
| MD5 |
4ecc32a36378bf415e0f0dbfe8e0ab5e
|
|
| BLAKE2b-256 |
4c46cf75f4c96879a0f63b2f21513321591771e80e6efd7674e8fc3f51dbde2d
|
File details
Details for the file yt2cli-0.1.2-py3-none-any.whl.
File metadata
- Download URL: yt2cli-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/7.1.6-201.fc44.x86_64
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73f59bb5d93366d5dcb61afe07828b68e9e6c568324a8bb41a889a6b30f1f1e2
|
|
| MD5 |
fbc71a3b1606c6bb3aa7b84d20146a48
|
|
| BLAKE2b-256 |
03e6141849e59a5b7f4b9c7a57b2820a4c206be4295a3ddb06a0fa286b5a1953
|