Skip to content

Repository files navigation

GitHub ReleaseGitHub IssuesGitHub Pull RequestsLicense

PyPI VersionPython Versions

Quality Gate StatusSecurity RatingReliability RatingMaintainability RatingVulnerabilitiesTechnical Debt


Logo

spotify-utils

An awesome and easy-to-use CLI & TUI for various Spotify® utility tasks!
Report Bug · Request Feature

About The Project

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.

Key features

  • 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.

Getting Started

Prerequisites

  • Python 3.10+

Installation

pipx install spotify-utils

Configuration

All 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'

Usage and examples

In this section you can find usage examples of the CLI

Launch the interactive TUI

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

List all playlists of the current user in JSON format

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"
}
}
]

Find duplicates across all playlists and display additional details

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 |
| ... | ... | ... | ... | ... |

Find removed or unavailable tracks across all playlists

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 |
| ... | ... | ... | ... | ... |

Export playlists as HTML

spotify-utils playlists export --format html

HTML export

Export specific playlist as JSON

spotify-utils playlists export --format json --id {PLAYLIST_ID}

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the Apache License 2.0. See LICENSE for more information.

Disclaimer

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®

About

An awesome and easy-to-use CLI for various Spotify® utility tasks

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages