An awesome and easy-to-use CLI & TUI for various Spotify® utility tasks!
Report Bug
·
Request Feature
spotify-utils is a lightweight command-line tool that takes care of the Spotify® housekeeping the official
clients don't. Authenticate once with your own Spotify® app credentials and you get a fast, scriptable way to
inspect, export, and clean up your playlists — either from plain CLI commands or from an interactive terminal UI.
Everything talks directly to the Spotify® Web API, output is available in formats you can pipe into other tools
(JSON) or hand to a human (console tables, HTML), and authentication is lazy so commands like --help and version
work without any configuration.
- Interactive TUI — a Textual-based terminal UI with tabs for browsing playlists and their tracks, scanning for duplicates, finding unavailable tracks, and exporting — all fully keyboard navigable and non-blocking.
- List playlists — show every playlist of the authenticated user as a console table or as JSON.
- Export playlists — export all playlists or a single playlist by ID to JSON or to a self-contained HTML report.
- Find duplicates — scan your owned playlists for tracks that appear in more than one playlist, with an optional detailed breakdown of which playlists each duplicate lives in.
- Find unavailable tracks — detect tracks in your owned playlists that have been removed from Spotify® or are greyed out (unavailable) in your market, including the reason why.
This CLI won't serve every need — more features are planned. Suggestions are welcome: fork the repo and open a pull request, or open an issue.
- Python 3.10+
pipx install spotify-utilsAll methods require user authorization. You will need to register your app at Spotify Developer Dashboard to get the credentials necessary to make authorized calls. Click here to go to the step-by-step guide for creating a Spotify® application.
The CLI uses the Authorization Code Flow, which the user logs into once. It provides an access token that can be refreshed.
Environment variables are being used for configuration. In order for the CLI to function properly you need to provide the following environment variables (use export instead of SET on Linux):
set SPOTIFY_UTILS_CLIENT_ID='your-spotify-client-id'
set SPOTIFY_UTILS_CLIENT_SECRET='your-spotify-client-secret'
set SPOTIFY_UTILS_REDIRECT_URI='your-app-redirect-url'In addition, the use of an .env file is supported:
SPOTIFY_UTILS_CLIENT_ID='your-spotify-client-id'
SPOTIFY_UTILS_CLIENT_SECRET='your-spotify-client-secret'
SPOTIFY_UTILS_REDIRECT_URI='your-app-redirect-url'
In this section you can find usage examples of the CLI
spotify-utils tui
The TUI provides four tabs:
- Playlists — browse all your playlists in a table; click a row to view its tracks
- Duplicates — scan your owned playlists and list any duplicate tracks
- Unavailable — scan your owned playlists for removed or greyed-out tracks
- Export — select a playlist (or all), choose JSON or HTML, and pick an output directory
Key bindings: Ctrl+L Playlists · Ctrl+D Duplicates · Ctrl+U Unavailable · Ctrl+E Export · Ctrl+Q Quit
spotify-utils playlists list --format json
[
{
"collaborative": false,
"description": "Car Music Mix 2022 🔥 Best Remixes of Popular Songs 2022 EDM, Bass Boosted by Rise Music",
"external_urls": {
"spotify": "https://open.spotify.com/playlist/0fM4AkfoGygOHVXjsNB7io"
}
}
]spotify-utils playlists duplicates --verbose
Output:
Found 43 duplicate tracks across 20 playlists
| Index | Name | Artists | Playlists | Track ID |
|-------|-------------------|-------------------------|------------------------|------------------------|
| 0 | Piercing Light | League of Legends, Mako | Rock, Sonos Mainstream | 0163ud7I4Vb0ID5K7WBkq9 |
| 1 | Edge Of The Earth | Thirty Seconds To Mars | Rock, Pop | 0g9IOJwdElaCZEvcqGRP4b |
| ... | ... | ... | ... | ... |
spotify-utils playlists unavailable --verbose
Output:
Found 3 unavailable tracks across 20 playlists
| Index | Name | Artists | Playlist | Reason |
|-------|-----------------|-------------|----------|---------|
| 0 | (removed track) | | Rock | removed |
| 1 | Some Song | Some Artist | Pop | market |
| ... | ... | ... | ... | ... |
spotify-utils playlists export --format html
spotify-utils playlists export --format json --id {PLAYLIST_ID}
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the Apache License 2.0. See LICENSE for more information.
Important
This project isn’t endorsed by Spotify AB and doesn’t reflect the views or opinions of Spotify AB or anyone officially involved in producing or managing Spotify®
