Skip to main content

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

Project description

GitHub Release GitHub Issues GitHub Pull Requests License

PyPI Version Python Versions

Quality Gate Status Security Rating Reliability Rating Maintainability Rating Vulnerabilities Technical 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®

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spotify_utils-2.1.1.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spotify_utils-2.1.1-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file spotify_utils-2.1.1.tar.gz.

File metadata

  • Download URL: spotify_utils-2.1.1.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for spotify_utils-2.1.1.tar.gz
Algorithm Hash digest
SHA256 c2e45e11e2956c257b1e0c6550b6fc0c300b6e865e643fe1157c01de51fd9a02
MD5 c73eda1ef6169ec713255ed77a80385f
BLAKE2b-256 65648a09480b7f25f5d1988c771655410a739b048bb516d0ad7e24ce2bce9824

See more details on using hashes here.

Provenance

The following attestation bundles were made for spotify_utils-2.1.1.tar.gz:

Publisher: build.yml on fabieu/spotify-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spotify_utils-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: spotify_utils-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for spotify_utils-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 99242158607c27caab59d21c6657deeffcd8e3949aea4ec9a23e5a450cb1fc80
MD5 b3801f1ff14995d07215b7d10d076543
BLAKE2b-256 161ae7336ec179309e65603a1b35c2c2b8f0fe66e6cb807878680ce0c2c2ccac

See more details on using hashes here.

Provenance

The following attestation bundles were made for spotify_utils-2.1.1-py3-none-any.whl:

Publisher: build.yml on fabieu/spotify-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page