A small collection of Python scripts for managing and analyzing your Spotify Liked Songs library.
| Script | Description |
|---|---|
sync_spotify.py |
Syncs your Liked Songs to a public playlist (no duplicates) |
analyze_liked_songs.py |
In-depth analysis: top artists, genres, release years, duplicates |
list_all_artists.py |
Alphabetical list of all artists in your library with track counts |
- Python 3.9+
- A Spotify Developer App (free)
uv(recommended) orpip
- Go to developer.spotify.com/dashboard and create a new app.
- In the app settings, add
http://127.0.0.1:8888/callbackas a Redirect URI. - Copy your Client ID and Client Secret.
cp .env.example .envOpen .env and fill in your values:
SPOTIPY_CLIENT_ID=your_client_id_here
SPOTIPY_CLIENT_SECRET=your_client_secret_here
SPOTIPY_REDIRECT_URI=http://127.0.0.1:8888/callback
SPOTIFY_PUBLIC_PLAYLIST_ID=your_playlist_id_hereFinding your playlist ID: Open the playlist in Spotify, click Share → Copy link. The ID is the string after
/playlist/and before?.
With uv (recommended):
uv run sync_spotify.pyuv reads inline dependency metadata and installs everything automatically.
With pip:
pip install spotipy python-dotenv
python sync_spotify.pyOn the first run, your browser will open and ask you to authorize the app.
After confirming, you will be redirected to 127.0.0.1:8888/callback.
Copy the full URL from the browser and paste it into the terminal when prompted.
A .cache file will be created locally to store the token for future runs.
# Sync Liked Songs to your public playlist
uv run sync_spotify.py
# Analyze your library
uv run analyze_liked_songs.py
# List all artists alphabetically
uv run list_all_artists.pyspotify-library-tools/
├── config.py # Shared auth and config helpers
├── sync_spotify.py
├── analyze_liked_songs.py
├── list_all_artists.py
├── .env # Your secrets — never commit this
├── .env.example # Template for .env — safe to commit
├── .gitignore
└── README.md
The .env file contains sensitive credentials and is excluded from version control via .gitignore.
Never commit your actual CLIENT_SECRET to a repository.
If you accidentally expose it, revoke it immediately in the Spotify Developer Dashboard.
MIT