Skip to main content

zenplayer

A terminal-based YouTube Music client with album-art now-playing display, bass-reactive glow, and session persistence.

Features

  • Search & play YouTube music directly from the terminal
  • Album art now-playing — track thumbnails rendered as truecolor half-block art filling the player panel, with a title/artist/progress-bar overlay
  • Bass-reactive glow — the overlay background pulses with the music's low-end energy (40–240 Hz FFT)
  • Dual-screen layout — player view with search sidebar, toggled via ctrl+p
  • Full-screen search — debounced (300ms), cached (5min TTL) async search with configurable result depth
  • Search preview — arrow through results to see a thumbnail and word-wrapped description in the sidebar
  • mpv-backed playback — seek, volume, pause, next/previous via IPC over Unix socket
  • Clickable controls — prev/play/next buttons in the controls bar are mouse-clickable
  • Volume persistence — volume changes are saved to the config file
  • History — last played tracks stored with playback position; browse, play, remove, or clear entries
  • Session persistence — quitting saves the current track + position (−10s); on restart, press r to resume
  • Zen mode — minimal, visually dampened full-screen view with just title, artist, and basic controls
  • Stall-resistant output — a non-blocking terminal writer with drop detection that self-recovers on slow terminals
  • Thumbnail caching — cover art cached on disk for instant replays

Requirements

  • Python 3.11+
  • mpv — audio playback engine (tested with 0.41.0)
  • A truecolor-capable terminal for full-quality album art (falls back gracefully otherwise)

Optional (for bass-reactive glow)

  • PulseAudio — pactl and parec are used to capture live audio for the FFT bass analysis. Without these, the bass-reactive glow is disabled but all other features work.

Install

From PyPI

pip install zenplayer

From source

git clone https://github.com/bjornramberg/zenplayer.git
cd zenplayer
pip install .

Platform-specific mpv install

# macOS
brew install mpv

# Ubuntu / Debian
sudo apt install mpv

# Arch
sudo pacman -S mpv

# Fedora
sudo dnf install mpv

Usage

zenplayer

Or run as a Python module:

python -m zenplayer

The search bar is focused on startup — just start typing to search. Press escape to unfocus it and use keyboard shortcuts.

Keyboard shortcuts

Global (all screens):

Key Action
space Play / Pause
→ / ← Seek forward / backward 5s
shift+→ / shift+← Seek forward / backward 30s
+ / - Volume up / down (5% steps)
shift++ / shift+- Volume up / down (15% steps)
j / k Next / Previous track
f or / Focus search input
h Toggle history screen
r Resume last session
q Quit
escape Unfocus search / Close overlays

Player screen:

Key Action
f1 Toggle zen mode

History screen:

Key Action
enter Play selected track (resumes from saved position)
backspace / delete Remove selected entry
ctrl+u Clear all history
escape Close history

Zen mode

Press f1 to toggle zen mode — a minimal, visually dampened view that hides the search panel, album art, queue, and controls bar. Only the track title, artist, duration, and prev/play/next buttons are shown. Press f1 again to return to the full view.

History

Press h to open the history screen — a full-screen overlay showing all previously played tracks (newest first). Select a track and press enter to play it from where you last left off. History entries show the saved position next to the duration.

Session persistence

When you quit the app (q), the current track and playback position (−10s) are saved. On the next startup, a "Press r to resume where you left off" banner appears. Press r to continue from the saved position.

Configuration

~/.config/zenplayer/config.json:

{
  "volume": 50,
  "reactive_fps": 24,
  "search_limit": 30,
  "history_limit": 100
}
Key Description Default
volume Initial volume (0–100); updated in-app and persisted 50
reactive_fps How often the bass analysis runs and the glow updates 24
search_limit How many results each search fetches 30
history_limit Max entries stored in play history 100

Data files

Path Contents
~/.config/zenplayer/config.json Volume, FPS, limits, last session
~/.cache/zenplayer/thumbs/ Cached YouTube thumbnails
~/.cache/zenplayer/history.json Play history with positions
~/.cache/zenplayer/search/ Cached search results (JSON, 5min TTL)

Architecture

zenplayer/
├── __init__.py             # Package version
├── __main__.py             # Entry point: main()
├── app.py                  # ZenPlayer(App) shell, CSS, keybindings, bass-reactive tick
├── config.py               # JSON config at ~/.config/zenplayer/config.json
├── diagnostics.py          # Stall sampler + tick/state logging (troubleshooting)
├── nonblocking_output.py   # Non-blocking terminal writer w/ drop detection
├── audio/
│   ├── analyzer.py         # AudioAnalyzer — FFT + bass-power extraction via numpy
│   ├── capture.py          # AudioCapture — parec/arecord subprocess for live audio
│   ├── extractor.py        # yt-dlp search + TrackInfo dataclass
│   └── player.py           # MpvPlayer — mpv subprocess + Unix socket IPC
├── screens/
│   ├── player_screen.py    # Main player layout (album art + search sidebar + controls)
│   ├── search_screen.py    # Full-screen search overlay (debounced, 300ms)
│   └── history_screen.py   # Full-screen history overlay
├── widgets/
│   ├── _art.py             # Shared half-block render helpers (quantize, run-merge)
│   ├── album_art.py        # AlbumArt — full-panel truecolor half-block art
│   ├── controls.py         # Controls — prev/play/next buttons + volume bar + time
│   ├── now_playing.py      # NowPlayingOverlay — title/artist/progress + bass glow
│   ├── queue_view.py       # QueueView — horizontal queue display
│   ├── resume_prompt.py    # ResumePrompt — "Press r to resume" banner
│   ├── search_preview.py   # SearchPreview — square thumbnail + description
│   ├── search_results.py   # SearchResults — ListView of SearchResultItems
│   └── zen_now_playing.py  # ZenNowPlaying — minimal centered view for zen mode
└── utils/
    ├── cache.py            # Search result disk cache with TTL
    ├── format.py           # Duration formatting helpers
    ├── history.py          # Play history persistence with positions
    └── thumbnail.py        # Thumbnail fetch + disk cache

How the album art works

  1. When a track starts, AlbumArt kicks off a background worker that fetches the YouTube thumbnail (hqdefault.jpg) and caches it at ~/.cache/zenplayer/thumbs/
  2. The image is center-cropped to the player panel's aspect ratio, downscaled to W×2H pixels (W×H terminal cells), and quantized to a 128-color palette (no dithering)
  3. Each cell is rendered with the ▀ half-block: the top pixel as foreground color and the bottom pixel as background color, giving full 2× vertical resolution. Consecutive cells sharing the same color pair are run-length-merged into a single span, so a 188×78 panel renders ~1.2k spans instead of ~14.7k (about 12× fewer rich styles and ~12× faster repaints)
  4. A NowPlayingOverlay docked at the bottom shows the title, artist, and a progress bar; its background glows and tints red in sync with bass energy from a 40–240 Hz FFT band
  5. While a thumbnail loads (or if none is available) a deterministic gradient cover derived from the track id is shown instead; pausing appends "(paused)" to the artist line

License

MIT License

Metadata

Release files for zenplayer 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zenplayer 0.3.0
File Size Uploaded Provenance Actions
zenplayer-0.3.0.tar.gz 36.5 kB With provenance Details for zenplayer-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zenplayer 0.3.0
File Interpreter ABI Platform Actions
zenplayer-0.3.0-py3-none-any.whl Python 3 none any Details for zenplayer-0.3.0-py3-none-any.whl

Total release size: 74.5 kB

Release files / zenplayer-0.3.0.tar.gz

Download URL zenplayer-0.3.0.tar.gz
Size 36.5 kB
Tags Source
SHA-256 checksum
How to use checksums
70f12087da70671433b7d696905af51929fb24f2c79063863a4d504672b15c3b
BLAKE2b-256 checksum
How to use checksums
936246bfa6ea6b382744a353079da3ff6bb36ece2e0f83bb82d8933d31453bd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / zenplayer-0.3.0-py3-none-any.whl

Download URL zenplayer-0.3.0-py3-none-any.whl
Size 37.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bbc06d02d80926c12c37a4f6068fbbd469c15d8bb7bdc1f8591c4f223c3a6e8
BLAKE2b-256 checksum
How to use checksums
893de0ee5075ec2fb7e2baa6753c5f2f3fd5329b410088613780f2222aff2b73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Security for zenplayer 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zenplayer-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files Full provenance

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