Skip to main content

Python utility to manipulate, and report on, Spotify playlists.

Project description

spotify-playlist-utility logo

Spotify-Playlist-Utility

Python utility to archive, restore, & shuffle Spotify playlists.

Spotify's service has a few downsides. Fortunately, they offer a fairly nice Web API. To fill in these feature gaps, I developed a Python cmd line utility which offers the following features:

  • Export: Spotify Saved (Liked) Tracks -> CSV track listing
  • Export: Spotify Playlist -> CSV track listing
  • Import: CSV track listing -> Spotify Playlist
  • List: Spotify Playlists (name & track count)

Project Context:

Long ago, I informally self-taught myself Python in a mostly hobby capacity. As my cybersecurity/IT career has progressed, I've worked to formalize my Python skills so that I could write compliant, well-documented, open-source ready, and packaged/deployable Python packages.

I used this project idea as an opportunity to build out a full-fledged Python project repo. For example, this project...

  • has a package with various modules within it
  • is easily distributable: .tar.gz/.whl support and on the Python Package Index (PyPI/pip)
  • has sphinx auto-generated docs documenting classes/functions
  • includes .vscode configs for easy development in VS Code
  • config file support
  • command line option/argument style application
![license](https://img.shields.io/github/license/ryanwarrick/spotify-playlist-utility) ![GitHub last commit](https://img.shields.io/github/last-commit/ryanwarrick/spotify-playlist-utility) [![GitHub issues](https://img.shields.io/github/issues/ryanwarrick/spotify-playlist-utility)](https://github.com/ryanwarrick/spotify-playlist-utility/issues) ![PyPI](https://img.shields.io/pypi/v/spotify-playlist-utility) /[![code with hearth by GITHUB_USERNAME](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-ryanwarrick-ff1414.svg?style=flat-square)](https://github.com/ryanwarrick)

Installation

Prerequisite: System must have Python 3.6+ installed (and pip - included with Python). See Python docs here for help installing.

Next, run the following pip command in the terminal to install the package from the Python Package Index:

python -m pip install spotify-playlist-utility

See gif illustrating pip install of the package: Install Demo

Setup/Configuration

This script interacts with Spotify's Web API via the spotipy open-source Python library. Therefore, we must register an application with Spotify's developer site and add the necessary data to a configuration file.

Steps:

  1. To get started using the API, create an app on Spotify's developer site.
    • Log in with your Spotify account credentials.
    • Click "Create an App"
    • Provide an app name/description and click "Create".
    • On the following page, click "Edit Settings".
    • Add "http://localhost:8888/callback" to the "Redirect URIs", click "add" then "save".
    • Take note of the "Client ID" and "Client Secret" on the Application Overview page.
  2. Create a customized configuration file for use by the package's 'spotify-playlist-utility' console command:
    • Download a copy of the template configuration file ('config.ini') found at the project root.
      • (Note: If you are working from source, you can grab the same file from your clone of the repo)
    • Edit the file to overwrite the placeholder values with the 'Client ID' and 'Client Secret' we previously noted in Step 1. You can leave 'RedirectURI' unmodified. See example below...
[DEFAULT]
ClientID = ABCDEFGHI
ClientSecret = 123456789
RedirectURI = http://localhost:8888/callback

Usage/Examples

For help, execute the following in the console

spotify-playlist-utility --help

Export Spotify Playlist Tracks (to .csv file)

spotify-playlist-utility <config_ini_file_path> -p <output_csv_file_path>

Export Playlist Tracks Demo

Import Tracks to Spotify Playlist (from matching .csv file)

spotify-playlist-utility <config_ini_file_path> -i <input_csv_file_path>

Import Tracks to Playlist Demo

Shuffle Spotify Playlist Tracks

spotify-playlist-utility <config_ini_file_path> -z

Shuffle Playlist

Contributors

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-playlist-utility-0.0.3.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

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

spotify_playlist_utility-0.0.3-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file spotify-playlist-utility-0.0.3.tar.gz.

File metadata

  • Download URL: spotify-playlist-utility-0.0.3.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for spotify-playlist-utility-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a40ff1d6504de82e6ba904d597ca09a2ed908569a908d1042d8b549ec0376511
MD5 5c34c3f31ede7db74b49b73ac9a32852
BLAKE2b-256 b01b3e9b863f0f1ca451e5abe54b50970a2393869a10b66f4113ab4965c059fd

See more details on using hashes here.

File details

Details for the file spotify_playlist_utility-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: spotify_playlist_utility-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1

File hashes

Hashes for spotify_playlist_utility-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 37889150acd0b98fc0b4d1bc4ffe1d2cd36d38c540603efe08c84253ee6c11e3
MD5 f60a600b67e2cb31541a3daef6b7f984
BLAKE2b-256 9e7d372c63e9736f5f9eeba4fb7af040a72318fd65c322a49510a1633848301f

See more details on using hashes here.

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