Skip to content

Athanasioust/Spotify-Analyser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spotify Playlist Analyzer

A Python application to analyze, compare, merge, and build Spotify playlists — with both a terminal (CLI) and graphical (GUI) interface.

Files

File Description
spotify_analyzer.py Terminal / CLI version
spotify_analyzer_gui.py Graphical (Tkinter) version
requirements.txt Python dependencies

Features

  • 🎵 Playlist Loading — Load any public Spotify playlist via URL or ID
  • 📋 Track Listings — See all songs with artist, album, duration, and popularity
  • 📊 Statistics — Genre distribution, duration stats, popularity metrics, top artists
  • 🔄 Playlist Comparison — Find common and unique songs between two playlists, with similarity score
  • 🔀 Playlist Merging — Combine two playlists into a new one (duplicates removed)
  • 📥 YouTube Tracklist Import — Paste a YouTube timestamp tracklist and automatically search each song on Spotify, then add found tracks to a new or existing playlist

Setup

1. Install Dependencies

py -3.9 -m pip install spotipy==2.23.0

2. Get Spotify API Credentials

  1. Go to Spotify Developer Dashboard
  2. Log in and click Create app
  3. Fill in any name and description
  4. Set the Redirect URI to exactly:
    http://127.0.0.1:8888/callback
    
  5. Under APIs used, select Web API
  6. Save, then copy your Client ID and Client Secret from Settings

Note: Spotify no longer allows localhost as a redirect URI for apps created after April 9 2025. Use http://127.0.0.1:8888/callback exactly.

3. Run

Terminal version:

py -3.9 spotify_analyzer.py

GUI version:

py -3.9 spotify_analyzer_gui.py

Authentication Modes

When you first run either version, you choose a mode:

Mode What it does Needs browser login?
Read-Only View and analyze playlists No
Full Access Everything + create/modify playlists Yes (once)

Full Access is required for merging playlists and the tracklist import feature. Your token is cached locally so you only log in once.

CLI Menu

[1]  Setup / change API connection
[2]  Load main playlist
[3]  View playlist details
[4]  View playlist statistics
[5]  Load comparison playlist
[6]  Compare playlists
[7]  Merge playlists → new playlist
[A]  Import from YouTube tracklist → Spotify playlist
[8]  Clear main playlist
[9]  Clear comparison playlist
[0]  Exit

YouTube Tracklist Import

Paste a YouTube video description tracklist in this format:

[0:05](https://youtube.com/...) Artist - Song Title (Remix)
[5:08](https://youtube.com/...) Billie Eilish & Khalid - lovely

The timestamps and URLs are stripped automatically. Each song is searched on Spotify using a cascading strategy (tries with full remix info first, then falls back to the bare title). At the end you choose to add found tracks to a new or existing playlist.

Requires Full Access mode.

Statistics Provided

  • Duration — total playlist length, average song duration, track count
  • Genres — top 10 genres across all tracks
  • Popularity — average Spotify popularity score (0–100)
  • Artists — top 10 most featured artists

Comparison Features

  • Common songs between both playlists
  • Songs unique to each playlist
  • Similarity percentage

Troubleshooting

redirect_uri: Not matching Make sure your Spotify app has exactly http://127.0.0.1:8888/callback as a Redirect URI (not localhost).

fatal: detected dubious ownership (Git)

git config --global --add safe.directory "C:/path/to/your/project"

Fatal error in launcher (pip) Use py -3.9 -m pip install ... instead of pip install ... directly.

"Error fetching playlist"

  • Check the playlist URL is valid and the playlist is public
  • Verify your internet connection and that credentials are correct

.gitignore

Make sure these are in your .gitignore so credentials are never committed:

.cache
.spotify_cache_gui
__pycache__/
*.pyc

License

Open source, available for educational purposes.

About

Analyze personal Spotify listening data using the Spotify Web API, with insights on top artists, tracks, genres, and listening habits.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages