What do you do when you've accumulated a decade's worth of carefully curated Spotify playlists, organized month by month? For me, it's not just a matter of hitting the shuffle button. Each playlist is a chapter in a 10-year musical journey, each one connected with vivid memories. However, I found no existing tools that could analyze these specific playlists in the way I wanted.
The Playlist Explorer aims to fill this gap for. Built on the Spotify API , the script queries playlists based on your criterias (for me some basic regex). It assembles data structures that include the complete track list, frequency of song appearances across playlists, most-added artists, and more. There are several pre-defined outputs which provide a chance to explore your musical history, offering insights that might give you some inspiration for new plyalists.
- OAuth 2.0 Authentication
- Direct API calls to Spotify
- Caching for API results
- Query all "diary" playlists that follow a specific naming pattern.
- Query tracks of all filtered playlists
- Additional data analysis features
- Visualizations
- Python 3.x
- Requests
- Spotify API credentials
The script uses a regular expression pattern to filter playlists based on their naming schema. In my case, all my playlists follow a certain naming convention, and I've tailored the regex accordingly. You'll likely want to update this pattern to match your own naming conventions:
self.pattern = r'(Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember)(?: und (Januar|Februar|März|April|Mai|Juni|Juli|August|September|Oktober|November|Dezember))? \d{4} *- *+'
-
Install required packages:
pip install -r requirements.txt
-
Add your Spotify API credentials to
config.json
:{ "client_id": "your_client_id_here", "client_secret": "your_client_secret_here", "redirect_uri": "your_redirect_uri_here", "scope": "playlist-read-private, user-top-read" }
-
Run the main script:
python main.py
This is the entry point of the application. It imports necessary modules and sets up an HTTP server for capturing OAuth tokens.
- Loading Configs & Initialise Spotify
- OAuth 2.0 Flow
- Query Spotify
- Analyse Data
- Visualisations
This script handles all the Spotify API queries and OAuth2 authentication.
Contains a class `FilterAndAnalyseData` which is used for advanced data filtering and analysis.