ONCE-TUBE is a high-performance Terminal User Interface (TUI) built for TWICE fans (ONCE) and terminal enthusiasts. It allows you to search and stream YouTube videos or audio-only directly from your terminal with a sleek, magenta-themed aesthetic.
Built with Python, Textual, and yt-dlp, with a heavy focus on system efficiency and low resource consumption.
- Blazing Fast Search: Uses
yt-dlpfor efficient metadata scraping. - Optimized UI: Built with Textual's modern engine, customized for ultra-low CPU usage.
- Singleton Media Player: Ensures only one instance of
mpvis running at a time—no window clutter. - Hardware Acceleration: Automatically utilizes GPU decoding (
--hwdec=auto) to keep your CPU cool. - TWICE Themed: Custom color palette (#FF5FA2, #FCC89B, #FF3B81) for the ultimate aesthetic.
|
|
Capture 1: The main landing interface. Capture 2 & 3: Search functionality and integrated media playback.
As a developer focused on performance and system architecture, this project wasn't just about playing music; it was about solving common TUI bottlenecks:
- CPU Optimization: Reduced idle usage from 70% to ~5% by implementing batch updates in
DataTableand eliminating layout refresh loops. - Process Management: Implemented a cleanup system to prevent "zombie processes" when the app or media player is closed.
- Asynchronous Execution: All network calls and process spawning are handled asynchronously to keep the UI responsive.
Make sure you have these system dependencies installed:
If you use uv, just clone and run:
git clone [https://github.com/FarrelApriandry/once-tube-TUI.git](https://github.com/FarrelApriandry/once-tube-TUI.git)
cd once-tube
uv pip install -e .
once-tube
pip install .
once-tube
| Key | Action |
|---|---|
Enter |
Search or Select Video |
Esc |
Clear search input |
D |
Toggle Dark Mode |
Q |
Quit Application |
The styling is handled via once_tube.tcss. You can customize the colors and layouts there to fit your terminal's vibe.
-
Input Handling: This tool uses
asyncio.create_subprocess_execfor handling searches, which provides a layer of protection against common shell injection attacks by passing arguments as a list rather than a raw string. -
Protection Layer: This tool uses
asyncio.create_subprocess_execfor handling searches, which provides a layer of protection against common shell injection attacks by passing arguments as a list rather than a raw string. -
Query Sanitization Plan:
Note: Initial development included a plan to strictly sanitize and force-append "TWICE" to every query to ensure a focused experience. However, to maximize functionality and allow users the freedom to explore related content or other artists without breaking the core TUI logic, I decided to keep the search open-ended while maintaining a "TWICE-first" aesthetic.



