Skip to content

My 10-Year Music Diary - A Python tool for focused analysis of Spotify playlists, designed to explore a subset of your playlists

License

Notifications You must be signed in to change notification settings

Thukyd/SpotifyPlaylistExplorer

Repository files navigation

Spotify Playlist Explorer: My 10-Year Music Diary

Introduction

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.

Features

  • OAuth 2.0 Authentication
  • Direct API calls to Spotify
  • Caching for API results
  • Query all "diary" playlists that follow a specific naming pattern.

Todos

  • Query tracks of all filtered playlists
  • Additional data analysis features
  • Visualizations

Requirements

  • Python 3.x
  • Requests
  • Spotify API credentials

Configuration

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} *- *+'

Setup

  1. Install required packages:

    pip install -r requirements.txt
  2. 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"
    }
  3. Run the main script:

    python main.py

Scripts Overview

main.py

This is the entry point of the application. It imports necessary modules and sets up an HTTP server for capturing OAuth tokens.

  1. Loading Configs & Initialise Spotify
  2. OAuth 2.0 Flow
  3. Query Spotify
  4. Analyse Data
  5. Visualisations

spotify_queries.py

This script handles all the Spotify API queries and OAuth2 authentication.

filter_and_analyse_data.py

Contains a class `FilterAndAnalyseData` which is used for advanced data filtering and analysis.

About

My 10-Year Music Diary - A Python tool for focused analysis of Spotify playlists, designed to explore a subset of your playlists

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages