This project provides a simple Python tool to extract track names and artists from a Spotify playlist and save them to a text file. It consists of two scripts: one to fetch the playlist data and another to extract the playlist ID from a copied Spotify link.
- Extracts playlist ID from a Spotify URL in your clipboard.
- Retrieves all tracks from a playlist, including multiple artists per track.
- Saves the output as a text file in a
Spotifyfolder on your desktop. - Includes progress feedback for large playlists.
- Handles errors gracefully (e.g., invalid playlist IDs, missing API credentials).
- Python 3.x installed.
- A Spotify Developer account with API credentials (Client ID, Client Secret, Redirect URI).
- Required Python libraries:
spotipy,pyperclip.
-
Clone the repository:
git clone https://github.com/SilverHaze99/spotify-playlist-extractor.git cd spotify-playlist-extractor -
Install dependencies:
pip install spotipy pyperclip
-
Set up Spotify API credentials:
- Go to the Spotify Developer Dashboard.
- Create an app to get your
CLIENT_ID,CLIENT_SECRET, and set aREDIRECT_URI(e.g.,http://localhost:8888/callback). - Open
SongNameGrabber.pyand replace the placeholders:CLIENT_ID = "your_client_id_here" CLIENT_SECRET = "your_client_secret_here" REDIRECT_URI = "your_redirect_uri_here"
- Alternatively, set these as environment variables:
export SPOTIPY_CLIENT_ID="your_client_id_here" export SPOTIPY_CLIENT_SECRET="your_client_secret_here" export SPOTIPY_REDIRECT_URI="your_redirect_uri_here"
- Copy a Spotify playlist URL to your clipboard (e.g.,
https://open.spotify.com/playlist/4XEb8DUIrlGHBNPRlPtG0W). - Run the extractor script:
python extract_playlist_id.py
- Check the output:
- A text file (e.g.,
PlaylistName_Output.txt) will be created in~/Desktop/Spotify/. - The file contains tracks in the format:
Song Name - Artist1, Artist2.
- A text file (e.g.,
Playlist-ID: 4XEb8DUIrlGHBNPRlPtG0W
Fetching tracks... 0 loaded so far.
Fetching tracks... 100 loaded so far.
The playlist data was saved in 'C:\Users\YourName\Desktop\Spotify\PlaylistName_Output.txt'.
SongNameGrabber.py: Fetches playlist data from Spotify and saves it to a file. Can be used standalone with a playlist ID as an argument (python SongNameGrabber.py <playlist_id>).extract_playlist_id.py: Extracts the playlist ID from a Spotify URL in your clipboard and runsSongNameGrabber.py.
- Add support for custom output directories.
- Include album names or track durations in the output.
- Create a single-script version for simplicity.
Feel free to fork this repository, submit issues, or send pull requests with improvements!
This project is licensed under the terms of the MIT license. See LICENSE for details.
This tool uses the Spotify Web API but is not affiliated with or endorsed by Spotify.