An open-source project for fetching Spotify track and album data programmatically using Python and the Spotify API.
Spotipython is a Python project that utilizes the Spotify API to fetch detailed information about albums, artists, and tracks. Whether you have an album link or want to search for specific tracks, Spotipython provides scripts to gather the data you need programmatically.
The development of Spotipython was inspired by my passion for contributing to the world of music. As an active contributor to Musicbrainz, where my Musicbrainz ID is https://musicbrainz.org/user/DarthDemono, I've been actively involved in managing music tags and making data available to the world. My contributions to Musicbrainz reflect my commitment to the internet and the music community.
Spotipython is a Python project developed to leverage the Spotify API for fetching detailed information about albums, artists, and tracks. The program aims to provide data such as ISRC and UPC codes, which can be obtained from Spotify, contributing to the availability of valuable music data.
The decision not to include this backstory in the GitHub README was to maintain brevity and focus on the essential information about the project.
The project is organized with the following directory structure:
- Spotipython/
- spotify_album.py: Script to fetch information about a Spotify album and its tracks.
- spotify_search.py: Script to search for tracks on Spotify based on user input.
- spotify_client.py: Module defining the
SpotifyAPI
class for handling authentication and making requests to the Spotify API. - .env: Configuration file containing your Spotify API credentials (client_id and client_secret).
- functions.py: Module with utility functions used across different scripts.
- requirements.txt: File listing the Python dependencies required for the project.
Description: Main.py is a Python script designed to interact with the Spotify API. It provides functionality to fetch track and album data programmatically using Python.
Functionality:
- Defines a SpotifyAPI class that handles authentication and makes requests to the Spotify API.
- Provides methods to obtain an access token, fetch resources (like albums, artists, tracks), and perform searches.
- Fetches information about a Spotify album and its tracks.
- Displays detailed information about the album, such as total tracks, album type, artist followers, genres, and additional details for each track.
- Searches for tracks on Spotify based on user input (album, artist, explicit).
- Retrieves information about the tracks, filters them based on explicit content, and prints detailed information about each track, including album details and external links.
- Inputs: Album Link or {Album Name, Artist Name, Explicit (True or, False)}
python main.py
Follow the prompts and provide the Data when requested.
- Dotenv file contains your "client_id" and "client_secret."
- Get the client_id and client_secret from steps below and add it to this
- create this file:
client_id = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXX"
- Python 3:
requests>=2.26.0
python-dotenv>=0.19.2
- Spotify API Credentials:
- Client ID
- Client Secret
Follow this guide from Spotify Developers: How to get Spotify API Credentials
- Clone the repository:
git clone https://github.com/darthdemono/Spotipython.git cd Spotipython
- Install the required packages:
pip install -r requirements.txt
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please check the Contribution Guidelines before contributing.
Please review our Code of Conduct before participating in the project.