In this guide, we will show you how to set up a development environment for using SpotifyUtils.

Prerequisites

To set up the project do the following:

  1. Clone the repository: git clone https://madladsquad.com/docs/SpotifyUtilities
  2. Enter the repository folder
  3. Make sure you have Python 3 installed
  4. Create a virtual environment:
    1. Create the environment: python3 -m venv venv
    2. Activate the environment: source venv/bin/activate
      • Windows: run venv/bin/Activate.ps1
      • Fish shell: source venv/bin/activate.fish
      • csh: source venv/bin/activate.csh
      • Bash & other shells: source venv/bin/activate
  5. Install the required dependencies:
    1. Flask: pip install flask
    2. Spotipy: pip install spotipy
    3. iCalendar: pip install icalendar
    4. datetime(if not already installed): pip install datetime
    5. pathlib(if not already installed): pip install pathlib

For using the unofficial API

Some scripts make use of an unofficial Spotify API, using the sp-playcount-librespot server. To use it do the following:

  1. Clone the repository and enter it
  2. Install Java and Maven
  3. Run mvn clean package inside the cloned repository folder
  4. Run java -jar https://madladsquad.com/core/target/librespot-core-jar-with-dependencies.jar <spotify_username> <spotify_password>

The spotify_username is your username that can be found here, while spotify_password is the account password for your profile that you use to log in normally. Once you run the command once, you can rerun it without specifying a username or password.

Run the server once and check if it launches successfully.

Configuring for official API usage

Once you've installed everything required for using the official API, open a Spotify Developer account and create an application. Once you have created an application, do the following:

  1. On the Spotify developer dashboard, edit your application and add a redirect URI like this: http://localhost:5000/callback
  2. Create a top-level file in the SpotifyUtils folder called config.json
  3. Add the following data inside it:
    {
        "client_id": "<your application's client ID>",
        "client_secret": "<your application's client secret>",
        "redirect_uri": "http://localhost:5000/callback",
        "scope": ""
    }

Create a list of artists

Most utilities in this repository require a file containing a list of artists and their IDs to work correctly. The file should have the following syntax:

Arstist,<spotify id here>
Artist-With-Multiple-Profiles,<spotify id 1>,<spotify id 2>,...,<spotify id n>, <a number from 0-100>

If an artist has multiple profiles, we use the last integer argument as a percentage that is applied on all alternative profiles when adding monthly listeners and followers to the main account. For example, we may want only roughly 30% of listeners from alternative profiles to be added to the monthly listener count, so we input 30 in the last field.

An example file used in production can be found here.

For a normal example file, use the artists-list-example.csv provided with the repository. Simply rename it to artists-list.csv when you want to use it.