ytmusic-cli
A local terminal-based music player that allows you to provide a YouTube playlist URL and stream the songs sequentially.
It acts like a lightweight terminal music player without permanently downloading tracks to your disk. It delegates audio streaming and playback to mpv while resolving YouTube URLs using yt-dlp.
Requirements
- Python 3.12+
mpv(must be installed and available in your system PATH)
Installation
- Clone this repository.
- Set up a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Ensure
mpvis installed:- Windows:
winget install mpv.netorscoop install mpv - macOS:
brew install mpv - Linux:
sudo apt install mpv
- Windows:
Global Installation (Like npm)
If you want to use the ytmusic command from anywhere on your machine (similar to a global npm package), we recommend using pipx.
# From inside the project folder:
pipx install .
(If you don't have pipx, you can install it first with pip install pipx)
Once installed globally, you can just run:
ytmusic "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"
Local Usage
If you prefer to run it locally without a global install:
play- Start or resume playbackpause- Pause playbackstop- Stop the current tracknext/n- Skip to the next trackprevious/prev/b- Go back to the previous trackqueue- Display the upcoming queuecurrent- Print the current player UI stateseek <seconds>- Seek forward or backward (e.g.,seek +30orseek -10)volume <0-100>- Set the playback volumequit/q- Exit the player
Authentication
If you need to access private playlists or YouTube Premium features, yt-dlp supports extracting cookies from your local browser session.
Create a configuration file at ~/.ytmusic/config.toml (e.g., C:\Users\YourName\.ytmusic\config.toml on Windows):
browser = "chrome"
volume = 80
autoplay = true
shuffle = false
Supported browsers: chrome, firefox, edge, brave, opera, safari, etc.
Testing
Run tests with pytest:
pytest tests/
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 ytmusic_tuieee-0.1.0.tar.gz.
File metadata
- Download URL: ytmusic_tuieee-0.1.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11da78d1d1a8d6a8b78d3c66a9fc59a831f5825e8bdd761ed9a28932450aef0c
|
|
| MD5 |
9cbeb9a99c00ed5ea8d399accfa7ef4f
|
|
| BLAKE2b-256 |
5ed4407aaf9a1d55ac557dc586e4e0c2af3398458889c5461701bb1021100394
|
File details
Details for the file ytmusic_tuieee-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ytmusic_tuieee-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81f9c4b9c55ccdbe50b14e0a443f58e83238d11cc51efbe36429b77e7859556c
|
|
| MD5 |
b5795fc5faf0e915be375f69e054066f
|
|
| BLAKE2b-256 |
adf6805c8528981711a32c922519eb72eb8cb3e038a22a4561b3db8d4b602baa
|