This repository is a living collection of scripts and examples for different use cases of the Spotipy library, a Python library for the Spotify Web API.
This repository contains examples utilizing the Spotipy library to interact with the Spotify Web API.
- Spotify Developer account: Register your app on https://developer.spotify.com/ to get
Client ID
andClient Secret
. - Set
SPOTIPY_CLIENT_ID
,SPOTIPY_CLIENT_SECRET
,SPOTIPY_REDIRECT_URI
as environment variables. - Detailed environment setup guide: YouTube tutorial.
The script sorts Spotify playlists by artist popularity and followers. It addresses the Spotify API's limitation on fetching data (max 100 items per request) by making paginated requests. This approach allows handling playlists with more than 100 tracks. Example: "Seen Live" Spotify playlist with 400+ tracks
- Retrieves playlist tracks and associated artist data in batches of 100.
- Sorts tracks by artist popularity and followers.
- Creates a new playlist with the sorted tracks.
Run the script, enter the playlist URL, and a sorted version of the playlist will be created in your Spotify account. This method is effective for large playlists exceeding 100 tracks.
References within the script include the Spotify Developer portal for obtaining necessary credentials and a YouTube tutorial for setup instructions.