Skip to main content

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

  1. Clone this repository.
  2. Set up a virtual environment:
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:
    pip install -r requirements.txt
    
  4. Ensure mpv is installed:
    • Windows: winget install mpv.net or scoop install mpv
    • macOS: brew install mpv
    • Linux: sudo apt install mpv

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 playback
  • pause - Pause playback
  • stop - Stop the current track
  • next / n - Skip to the next track
  • previous / prev / b - Go back to the previous track
  • queue - Display the upcoming queue
  • current - Print the current player UI state
  • seek <seconds> - Seek forward or backward (e.g., seek +30 or seek -10)
  • volume <0-100> - Set the playback volume
  • quit / 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

ytmusic_tuieee-0.1.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ytmusic_tuieee-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

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

Hashes for ytmusic_tuieee-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11da78d1d1a8d6a8b78d3c66a9fc59a831f5825e8bdd761ed9a28932450aef0c
MD5 9cbeb9a99c00ed5ea8d399accfa7ef4f
BLAKE2b-256 5ed4407aaf9a1d55ac557dc586e4e0c2af3398458889c5461701bb1021100394

See more details on using hashes here.

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

Hashes for ytmusic_tuieee-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81f9c4b9c55ccdbe50b14e0a443f58e83238d11cc51efbe36429b77e7859556c
MD5 b5795fc5faf0e915be375f69e054066f
BLAKE2b-256 adf6805c8528981711a32c922519eb72eb8cb3e038a22a4561b3db8d4b602baa

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page