Setting up for development - MadLadSquad/SpotifyUtilities GitHub Wiki
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:
- Clone the repository:
git clone https://github.com/MadLadSquad/SpotifyUtilities
- Enter the repository folder
- Make sure you have Python 3 installed
- Create a virtual environment:
- Create the environment:
python3 -m venv venv
- 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
- Windows: run
- Create the environment:
- Install the required dependencies:
- Flask:
pip install flask
- Spotipy:
pip install spotipy
- iCalendar:
pip install icalendar
- datetime(if not already installed):
pip install datetime
- pathlib(if not already installed):
pip install pathlib
- Flask:
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:
- Clone the repository and enter it
- Install Java and Maven
- Run
mvn clean package
inside the cloned repository folder - Run
java -jar ./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:
- On the Spotify developer dashboard, edit your application and add a redirect URI like this:
http://localhost:5000/callback
- Create a top-level file in the
SpotifyUtils
folder calledconfig.json
- 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.