https://github.com/naarvent/spotify-tui
A terminal-based Spotify client built with Python, Spotipy and Textual. It provides a keyboard-driven TUI for searching, browsing and controlling Spotify playback, viewing synced lyrics, managing playlists and devices, and more. It's inspired by Rigellute's "spotify-tui".
https://github.com/naarvent/spotify-tui
cli english hotkeys keyboard media-control python script spotify spotify-api spotify-tui spotipy spotipy-api spotipy-library terminal terminal-based
Last synced: 4 months ago
JSON representation
A terminal-based Spotify client built with Python, Spotipy and Textual. It provides a keyboard-driven TUI for searching, browsing and controlling Spotify playback, viewing synced lyrics, managing playlists and devices, and more. It's inspired by Rigellute's "spotify-tui".
- Host: GitHub
- URL: https://github.com/naarvent/spotify-tui
- Owner: naarvent
- License: mit
- Created: 2025-10-27T17:08:06.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-01-12T17:06:47.000Z (5 months ago)
- Last Synced: 2026-01-12T22:54:35.673Z (5 months ago)
- Topics: cli, english, hotkeys, keyboard, media-control, python, script, spotify, spotify-api, spotify-tui, spotipy, spotipy-api, spotipy-library, terminal, terminal-based
- Homepage:
- Size: 60.5 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Spotify TUI β SPT (Python) π§π
[](https://opensource.org/licenses/MIT) [](https://www.python.org/) [](https://github.com/naarvent/Spotify-From-Terminal/issues) [](https://github.com/naarvent/Spotify-From-Terminal/stargazers)
---
### [Demo on YouTube!](https://youtu.be/MJm7DcUdPUs)
[](https://youtu.be/MJm7DcUdPUs)
---
## Important: If the app gets stuck on startup, delete the OAuth cache file Documents/naarvent's projects/Spotify_TUI/.cache_spotify_token to force re-authentication.
---
A terminal-based Spotify client built with Python, Spotipy and Textual. It provides a keyboard-driven TUI for searching, browsing and controlling Spotify playback, viewing synced lyrics, managing playlists and devices, and more.
---
## Table of Contents π
- [Summary π](#summary-)
- [Features β¨](#features-)
- [Requirements & Installation π οΈ](#requirements--installation-οΈ)
- [Environment & Credentials π](#environment--credentials-)
- [How it works (high level) βοΈ](#how-it-works-high-level-οΈ)
- [APIs & External Services π](#apis--external-services-)
- [Keybindings / Controls β¨οΈ](#keybindings--controls-οΈ)
- [Configuration & Cache π](#configuration--cache-)
- [Troubleshooting & Notes π](#troubleshooting--notes-)
- [License π](#license-)
---
## Summary π
`spt` is a full-featured TUI for Spotify built using:
- **Textual** for the terminal UI
- **Spotipy** for the Spotify Web API
- **Requests** for lyrics and metadata providers
It supports search, playback, playlists, devices, lyrics, multi-selection workflows, and rich UI panels.
---
## Features β¨
- Full Spotify search (tracks, albums, artists, playlists)
- Playback control: play / pause / next / previous / seek / shuffle / repeat
- Synced LRC lyrics when available; plain lyric fallback
- Multi-review / multi-add batch playlist operations
- Playlist creation, import, and modification
- Device selection and playback transfer
- Real-time playback sync with progress bar
- Persistent cache + config + OAuth token storage
- Expandable / collapsible Library & Playlists panels via keyboard
---
## Requirements & Installation π οΈ
**Recommended:** Python 3.10+
Install dependencies:
```bash
pip install spotipy textual requests rich pyfiglet
```
Run the app:
```bash
python spt_tui.py
```
---
## Environment & Credentials π
`spt` requires Spotify credentials (or it will prompt you to provide them on first run):
- `SPOTIPY_CLIENT_ID`
- `SPOTIPY_CLIENT_SECRET`
- `SPOTIPY_REDIRECT_URI`
If not provided via environment variables, the app will prompt for them and can save them locally in `spt_config.json`.
Scopes include playback, playlists, library, and user data as defined in the script.
---
## How it works (high level) βοΈ
- Textual builds a two-column TUI: Search/Library/Playlists (left) and Details/Results/Lyrics (right).
- Spotipy handles authentication, tokens, and playback/playlist operations.
- Lyrics are fetched using LRCLib and lyrics.ovh, parsed into synced or pseudo-synced lines.
- A periodic task syncs playback state and updates the UI.
- Keyboard shortcuts drive all navigation and actions.
---
## APIs & External Services π
- **Spotify Web API** β playback, search, library, playlists, devices
- **LRCLib** β synced LRC lyrics
- **lyrics.ovh** β plain lyric fallback
---
## Keybindings / Controls β¨οΈ
Below are the keybindings as defined in the application (`spt_tui.py`). Use these keys to navigate and control the TUI.
### General / Navigation
- `escape` β Menu
- `ctrl+q` β Quit
- `up` β Up
- `down` β Down
- `/` β Search (focus search input)
- `left` β Move focus to the left column (sections, library, playlists). When a playlist/album/lyrics view is open in the right panel, pressing `Left` returns focus to the left column and effectively closes or exits the detailed right view so you can navigate other items.
- `right` β Move focus to the right panel (details, track list, lyrics). From the left column select an item and press `Right` (or `Enter`) to open it in the right panel; the right key focuses that panel for interaction.
### Main / Navigation
- `Esc` β Return to main menu
- `Ctrl+Q` β Quit
- `β / β` β Move between sections and list items
- `/` β Focus search input
- `Enter` β Open / Play selected item
### Open / Play / Playback
- `enter` β Open/Play
- `space` β Play/Pause
- `n` β Next
- `p` β Prev/Restart
- `r` β Repeat (cycle: off β context β track)
- `Ctrl+S` β Toggle shuffle
- `c` β Queue (add track to queue)
### Playback Controls
- `Space` β Play / Pause
- `n` β Next track
- `p` β Previous / Restart
- `r` β Cycle repeat (off β context β track)
- `c` β Add selected track to Queue
- `Ctrl+S` β Toggle shuffle
- `- / +` β Volume down / up (uses configured seconds using "<")
- `Ctrl+Left / Ctrl+Right` β Seek back / Seek forward (uses configured seconds using "<")
- `m` β Mute / Unmute
### Shuffle / Volume / Seek / Mute
- `ctrl+s` β Toggle shuffle
- `-` β Volume down (Vol -)
- `+` β Volume up (Vol +)
- `m` β Mute
- `ctrl+left` β Seek back (uses configured seconds using "<")
- `ctrl+right` β Seek forward (uses configured seconds using "<")
- `<` β Prompt seek settings
### Devices & Settings
- `d` β Open device manager (transfer playback)
- `<` β Open seek/volume settings
### Devices, Help & Views
- `d` β Manage devices
- `?` β Help
- `f1` β Help
- `l` β Toggle lyrics
- `ctrl+r` β Refresh
- `ctrl+c` β Open Queue
### Library & Playlist / Queue Management
- `f` β Toggle Favorite (Like / Unlike selected track)
- `Ctrl+Shift+P` β Add selected track(s) to a playlist
- `Ctrl+D` β Delete (playlist or remove item)
- `Ctrl+R` β Refresh / reload content
- `Ctrl+C` β Open Queue view
### Multi-Add / Selection Mode
- `Ctrl+L` β Toggle Multi-Add mode
- In Multi-Add: use movement keys and `Enter` to toggle selection
- `Ctrl+A` β Confirm selection (when prompted / in multi-add flows)
- `Ctrl+O` β Add all / confirm add-all action
### Additional / Help / Misc
- `?` or `F1` β Toggle Help view
- `Left / Right` arrows β Move focus between left column and right panel
- Log file: `Documents/naarvent's projects/Spotify_TUI/spt_py_textual_spotify.log`
---
## Configuration & Cache π
Default location for cache, config and logs (created under the user's Documents folder):
```
Documents/naarvent's projects/Spotify_TUI/
```
Files:
- `spt_config.json` β saved credentials
- `.cache_spotify_token` β OAuth token cache
- `spt_py_textual_spotify.log` β log file (rotating)
---
## Search β prefixes & smart parsing π
The app supports quick filters by starting the query with a prefix (case-insensitive). These are parsed by the search routine:
- `/ART ` β search artists
- `/ALB ` β search albums
- `/TRK ` β search tracks
- `/PLY ` β search playlists
- `/PDC ` β search podcasts
- `/EPS ` β search episodes from podcasts
You can also write natural queries (e.g., `FEEL.`)βthe app applies smart parsing and multiple candidate queries to maximize relevant results.
---
## Lyrics β sources & behavior π΅
`spt` attempts to provide synced and plain lyrics using multiple external services and local caching:
- LRCLib (`https://lrclib.net`) β primary source for synced LRC lyrics (fetches `.lrc` when available).
- lyrics.ovh (`https://api.lyrics.ovh`) β fallback for plain lyrics when synced versions are not found.
- Local lyrics cache stored under the same cache directory to avoid repeated network lookups.
If synced LRC lyrics are found, the app parses timestamps into a timeline and highlights the current line in sync with playback. If only plain lyrics are available, the app will generate a pseudo-timed timeline to display lines progressively.
If lyrics aren't showing, try `Ctrl+R` to refresh data or ensure the network and external services are reachable.
---
## Troubleshooting & Notes π
- If playlists don't load: press `Ctrl+R` (Refresh).
- Lyrics fall back to plain text if synced LRC is not available.
- Device switching requires an active Spotify client/device.
- Check `spt_py_textual_spotify.log` for detailed debug output.
---
## License π
This project is licensed under the MIT License β see the `LICENSE` file for details.