A lightweight, terminal-based music player for Plex Media Server with a modern TUI interface inspired by spotify-tui.
- 🎵 Browse Playlists - Navigate and play from your Plex music playlists
- 🔍 Search Tracks - Quick search across your music library
- ⚡ Fast Loading - Optimized for large playlists (64k+ tracks)
- 🎨 Modern TUI - Clean, interactive terminal interface using Textual
- 🎮 Keyboard Controls - Full keyboard navigation and playback control
- 💾 Smart Caching - Instant reload of previously loaded playlists
- 🎲 Shuffle Support - Randomize and play tracks
- Python 3.9+
plexapilibrarytextuallibrary (TUI framework)ffplay(part of ffmpeg) for audio playback
-
Install dependencies:
pip install plexapi textual
Or using requirements.txt:
pip install -r requirements.txt
-
Install ffmpeg (includes ffplay):
- macOS:
brew install ffmpeg - Linux:
apt install ffmpegoryum install ffmpeg
- macOS:
-
Configure your Plex server: Edit the configuration at the top of
plex-tui.py:PLEX_BASE_URL = "https://your-plex-server.com/" PLEX_TOKEN = "your-plex-token-here"
To get your Plex token, see: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
python3 plex-tui.pyOr if executable:
./plex-tui.pyThe TUI is divided into three main areas:
- Left Sidebar - Playlists list and search
- Right Panel - Track listing and now playing info
- Bottom Bar - Keybindings reference
| Key | Action |
|---|---|
↑ ↓ |
Navigate playlists/tracks |
Enter |
Load selected playlist or play selected track |
Space |
Play/Pause current track or start playing highlighted playlist |
n |
Next track |
p |
Previous track |
r |
Shuffle current playlist |
s |
Focus search input |
q |
Quit |
-
Browse Playlists:
- Use arrow keys to navigate the playlist list
- Press
Enterto load a playlist and see its tracks - Press
Spaceto start playing a highlighted playlist
-
Load Tracks:
- After loading a playlist, tracks are displayed in the main panel
- Navigate tracks with arrow keys
- Press
Enteron a track to play it
-
Large Playlists:
- Playlists with 1000+ tracks automatically use optimized loading
- Only the first 50 tracks are loaded initially (configurable)
- Full metadata (including artist names) is included
- Press
sto focus the search input - Type your search query
- Press
Enterto search - Results appear in the search results list
- Navigate and press
Enterto play a track
- Play/Pause: Press
Spacewhile a track is playing - Next Track: Press
n - Previous Track: Press
p - Shuffle: Press
rto randomize the current playlist
You can adjust these settings at the top of plex-tui.py:
LARGE_PLAYLIST_THRESHOLD = 1000 # Use library method for playlists with more tracks than this
LARGE_PLAYLIST_LIMIT = 50 # Number of tracks to load for large playlists (reduced for speed)
REGULAR_PLAYLIST_LIMIT = 100 # Number of tracks to load for regular playlists
MAX_API_RESULTS = 1000 # Maximum results to request from APIPLAYER_CMD = "ffplay" # Audio player command
PLAYER_ARGS = ["-nodisp", "-autoexit", "-loglevel", "quiet"] # Player argumentsTo see timing information and debug messages, set debug_mode = True in the __init__ method (line ~108).
The player is optimized for large music libraries:
- Smart Loading: Large playlists (>1000 tracks) use library methods instead of playlist iteration
- Caching: Loaded playlists are cached for instant reload
- Limited Initial Load: Only loads a subset of tracks initially to keep UI responsive
- API Optimization: Uses server-side limits to avoid fetching unnecessary data
For playlists with 64,000+ tracks, loading typically takes <1 second.
Install ffmpeg:
- macOS:
brew install ffmpeg - Linux:
apt install ffmpeg
The player will also check common Homebrew paths on macOS (/opt/homebrew/bin, /usr/local/bin).
- Verify
PLEX_BASE_URLis correct (includehttps://and trailing/) - Verify
PLEX_TOKENis valid - Check network connectivity to your Plex server
This typically happens with very large playlists. The player automatically uses optimized loading methods for playlists with 1000+ tracks, which includes full metadata. If you still see "Unknown", try:
- Reload the playlist (it will use the optimized method)
- Check that your Plex server has proper metadata for tracks
- Large playlists automatically use optimized loading
- First load may be slower; subsequent loads use cache
- Check your network connection to the Plex server
- Framework: Textual (Python TUI framework)
- Plex API: plexapi library
- Audio Player: ffplay (part of ffmpeg)
- Threading: Playback runs in background, controls are non-blocking
- Small Playlists (<1000 tracks): Uses
playlist.items()method - Large Playlists (>1000 tracks): Uses
library.search()with limit for faster loading - Recently Added: Uses
library.recentlyAdded()method for optimal performance - Caching: All loaded tracks are cached by playlist ratingKey
The player tries multiple methods to get artist names without making extra API calls:
- Direct attribute access (
grandparentTitle) - XML data parsing
- Fallback to API call if needed
This is a standalone script for personal use with your Plex Media Server.
- Inspired by spotify-tui
- Built with Textual
- Uses plexapi