Skip to content

Obtaining Track and Album Data from an Album Link or Using the Search Function via the Spotify API in Python

License

Notifications You must be signed in to change notification settings

darthdemono/Spotipython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotipython

An open-source project for fetching Spotify track and album data programmatically using Python and the Spotify API.

GitHub Issues GitHub Forks GitHub Stars License Last Commit Python Version

Introduction

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.

Project Structure

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.

Scripts

main.py

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)}

How to Use:

python main.py

Follow the prompts and provide the Data when requested.

Dotenv

  • 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:

.env

client_id = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
client_secret = "XXXXXXXXXXXXXXXXXXXXXXXX"

Requirements

  • Python 3:
  requests>=2.26.0
  python-dotenv>=0.19.2
  • Spotify API Credentials:
    • Client ID
    • Client Secret

How to Get Spotify API Credentials

Follow this guide from Spotify Developers: How to get Spotify API Credentials

Installation:

  1. Clone the repository:
    git clone https://github.com/darthdemono/Spotipython.git
    cd Spotipython
  2. Install the required packages:
    pip install -r requirements.txt

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution

Contributions are welcome! Please check the Contribution Guidelines before contributing.

Code of Conduct

Please review our Code of Conduct before participating in the project.

About

Obtaining Track and Album Data from an Album Link or Using the Search Function via the Spotify API in Python

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages