This repository is for the analysis of Spotify streaming history files obtained from the Spotify website.
-
Install Python (version 3 or greater)
-
Install the pipenv package with
pip install pipenv
-
Download your Spotify streaming data to the
data/MyData/
subdirectory
To download your data, you must request the data from the Spotify Account Privacy page. You will then be sent a link to download the data. Note that this step can take a few days.
- Obtain Spotify developer authorisation and store keys in
data/api_keys/api_dev_keys.txt
Authorisation can be obtained by following the steps listed on the Spotify website. Your two keys should be stored on separate lines within your text file.
Before calculating any statistics, perform the set-up steps specified in the README. With this step, you should have your own Spotify streaming history to analyse. You should also be able to make Spotify API calls.
To run the complete code and produce visualisations from your streaming history, run:
pipenv run main.py
This will produce a summary visualisation as well as extra visualisations for the top songs, artists, and genres. You can also use the following options with this command:
- -s (produce a summary visualisation)
- -t (produce a song (track) visualisation)
- -a (produce an artist visualisation)
- -g (produce a genre visualisation)
- -p (output a pdf of the main statistics)
- -k [path] (specify the path to the key file)
- -d [path] (specify the path to the data directory)
- -y [year] (specify the year to get statistics for)
To calculate individual statistics, instantiate the StreamingHistory
class with:
from StreamingHistory import StreamingHistory
You can then call any methods from the class.
Alternatively, you can create all visualisations with the src/create_visualisations.py
file.
-
cd src
-
pipenv run python create_visualisation.py
This file will be set up to run with the example data, so you will need to change the path to the data within the file.
-
Clone the repo and create a new branch
-
Make changes and test with
data/ExampleData/StreamingHistory0.json
-
Submit a Pull Request with description of changes
Where possible, please make sure that your changes conform to the Style Guide for Python Code (PEP8).