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.
Metadata
Release files for yt-music-tui 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yt_music_tui-1.0.1.tar.gz | 13.6 kB | Without provenance | Details for yt_music_tui-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yt_music_tui-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for yt_music_tui-1.0.1-py3-none-any.whl |
Total release size: 25.8 kB
Release files / yt_music_tui-1.0.1.tar.gz
| Download URL | yt_music_tui-1.0.1.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55f8b38826124eb2774ffe39a7c4abd1357567da6bf499f73cab9cc52ffd60f7
|
|
BLAKE2b-256 checksum How to use checksums |
8cc0db22855afeb35dbe9aa98c948e2e01f52b18c16620ce936b6d27517380cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / yt_music_tui-1.0.1-py3-none-any.whl
| Download URL | yt_music_tui-1.0.1-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10b038aa515fcf43afd17bbeebcc63152c006ffb3a659c02e9235cec8defab2a
|
|
BLAKE2b-256 checksum How to use checksums |
30635b28b2ec7c02a176cac40b888ffb34085781403e0d03e31ef8d551e008e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for yt-music-tui 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.