At some point Spotify decided to follow all artists of which i added a song to my library. This completely broke my recommendation algorithm. Deleting 1k+ artists was not an option, so I asked Cursor to automate that for me. This is the result of 5 minutes of vibe coding.
The python script allows you to:
- Check the total number of artists you currently follow.
- Unfollow ALL artists you currently follow after explicit confirmation.
1. Create a Spotify Developer Application:
- Go to the Spotify Developer Dashboard and log in with your Spotify account.
- Click
CREATE APP
. - Give your app a name (e.g., "Artist Unfollower Tool") and a description. Accept the terms.
- Once created, you'll see your Client ID. Click
SHOW CLIENT SECRET
to reveal your Client Secret. You will need both these values. - Go to the app's
Settings
. - Find the
Redirect URIs
section. Add the following URI exactly:http://localhost:8888/callback
- Scroll down and click
SAVE
. - IMPORTANT: Keep your Client ID and especially your Client Secret confidential. Do not share them publicly.
2. Create the .env
Configuration File:
- In the same directory where you saved
unfollow_artists.py
, create a new file named.env
(note the leading dot). - Open the
.env
file with a text editor and add your Spotify credentials in the following format, replacing the placeholders with your actual values from the Spotify Developer Dashboard:SPOTIPY_CLIENT_ID='YOUR_ACTUAL_CLIENT_ID' SPOTIPY_CLIENT_SECRET='YOUR_ACTUAL_CLIENT_SECRET' SPOTIPY_REDIRECT_URI='http://localhost:8888/callback'
Run the script from your terminal within the project directory. You must provide one of the following actions:
1. Check Followed Artist Count (check
)
To see how many artists you currently follow without making any changes:
python unfollow_artists.py check
- Authentication: The first time you run this (or if your login expires), the script will:
- Print a URL to your console.
- Open this URL in your default web browser (or ask you to copy/paste it).
- Ask you to log in to Spotify and authorize the application (granting permission for
user-follow-read
). - After authorization, Spotify will redirect you to a
http://localhost:8888/callback?code=...
URL. This page might show a "site can't be reached" error - this is normal. - Copy the complete URL from your browser's address bar.
- Paste the copied URL back into the terminal where the script is waiting and press Enter.
- The script will then authenticate and display the total count of artists you follow.
2. Unfollow ALL Artists (unfollow
)
To initiate the process of unfollowing all artists:
python unfollow_artists.py unfollow
- Authentication: Follow the same authentication steps as the
check
action if required. - Fetching: The script will fetch the list of all artists you follow, showing progress.
- Confirmation: It will display the total number of artists found and list the first few. Crucially, it will ask for confirmation:
Are you SURE you want to unfollow all <N> artists? (yes/no):
- Type
yes
and press Enter ONLY if you are absolutely certain. Typing anything else or just pressing Enter will cancel the operation. - Unfollowing: If confirmed, the script will proceed to unfollow artists in batches, printing progress and a summary at the end.
- Authentication Errors: If you encounter issues during authentication, try deleting the
.spotify_cache
file in the script's directory and running the script again. Ensure your Client ID, Client Secret, and Redirect URI in the.env
file exactly match the values in your Spotify Developer Dashboard app settings. ModuleNotFoundError
: Make sure you have installed the dependencies correctly usingpip install -r requirements.txt
in the correct directory.- Rate Limiting: The script includes a small delay between batches to help avoid Spotify API rate limits. If you encounter rate limit errors (often HTTP status code 429), you might need to wait a while before running the script again.
- Credentials Not Found Error: Double-check that your
.env
file exists in the same directory as the script, is named correctly (.env
), and contains the keys (SPOTIPY_CLIENT_ID
,SPOTIPY_CLIENT_SECRET
,SPOTIPY_REDIRECT_URI
) with your actual credentials.