A terminal-based YouTube Music player with smart filtering and smooth playback
Project description
yt-dlp Music TUI
A terminal-based YouTube Music player that plays audio-only streams using mpv and yt-dlp. It filters out non-music content (like reactions, tutorials, or long videos), provides smooth playback with a progress bar, and automatically builds a queue of similar tracks.
How It Works
- Uses
yt-dlpto search and fetch YouTube video metadata. - Filters results to prefer official music videos and exclude non-music content.
- Plays audio through
mpvin the background (no video). - Communicates with
mpvusing a Unix domain socket for real-time playback control (pause, volume, seek). - Maintains a play history and auto-generates a queue using YouTube's auto-mix feature.
- Renders a terminal user interface (TUI) with
cursesshowing current track, progress, and upcoming songs.
Requirements
- Python 3.7 or newer
mpv(media player)yt-dlp(video downloader)socatis not required (this version uses direct socket communication)
Note: This program does not download or save audio files. It streams audio directly from YouTube.
Installation
-
Install system dependencies
On Debian/Ubuntu:
sudo apt install mpv python3 python3-pip
On Arch/Manjaro:
sudo pacman -S mpv python
-
Install Python dependencies
pip3 install yt-dlp
-
Download the script
git clone https://github.com/exar1o/yt-music-tui.git
Or, if you have the file locally, skip this step.
-
Make it executable (optional)
cd yt-music-tui chmod +x yt_music_tui.py
Basic Usage
-
Run the program:
python3 yt_music_tui.py -
On first launch, it may show a warning about missing YouTube cookies.
- Press any key to continue without cookies (some videos may not play).
- Press
Sto skip this warning for the rest of the session.
-
Press
/to search for a song or artist. -
Use the following keys during playback:
- Space: Pause/resume
n: Skip to next tracks: Skip to a specific track number in the queuej/k: Increase/decrease volume,/.: Seek backward/forward by 10 secondsh: Toggle shuffler: Cycle repeat mode (off → one → all)c: Clear the queueq: Quit
Optional: Add YouTube Cookies (for age-restricted content)
Some videos require being logged into YouTube. To enable access:
- Install the "cookies.txt" extension in your browser.
- Go to youtube.com and log in.
- Click the extension icon and choose "Export".
- Save the file as
~/.yt-dlp-cookies.txt. - Set the environment variable (optional,
yt-dlpwill find it automatically):export YT_DLP_COOKIES=~/.yt-dlp-cookies.txt
After this, restart the program. The cookie warning will no longer appear.
Notes
- The program stores up to 100 played tracks in
~/.cache/yt_music_history.json. - The queue automatically refills when it gets low.
- Maximum track duration is 6 minutes by default (configurable in source).
Troubleshooting
- If you see "No results", try a more specific search query.
- If playback fails repeatedly, ensure you have an internet connection and consider adding cookies.
- If the TUI appears broken, make sure your terminal supports UTF-8 and has at least 80x24 size.
Project details
Release history Release notifications | RSS feed
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 yt_music_tui-1.0.1.tar.gz.
File metadata
- Download URL: yt_music_tui-1.0.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55f8b38826124eb2774ffe39a7c4abd1357567da6bf499f73cab9cc52ffd60f7
|
|
| MD5 |
6f0a2a73ed6d63bfb9fff1d98d50a9cc
|
|
| BLAKE2b-256 |
8cc0db22855afeb35dbe9aa98c948e2e01f52b18c16620ce936b6d27517380cc
|
File details
Details for the file yt_music_tui-1.0.1-py3-none-any.whl.
File metadata
- Download URL: yt_music_tui-1.0.1-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10b038aa515fcf43afd17bbeebcc63152c006ffb3a659c02e9235cec8defab2a
|
|
| MD5 |
c3efc429e8616de7ae75dd3848fd83bc
|
|
| BLAKE2b-256 |
30635b28b2ec7c02a176cac40b888ffb34085781403e0d03e31ef8d551e008e0
|