简体   繁体   中英

Is there a way to extract credits of a song/track on Spotify?

I was trying to see if I could extract the values of the credit section (Written by, Produced by, etc) off a spotify track.

Using the Spotipy library,I was told there was a function for the same, ( track_info['songwriters'] and track_audio_features(trackid) ) but they dont work anymore.

Just looking for a solution for the same, irrespective of the library:)

Eg:

In the song "Stormzy - Own It(Feat. Ed Sheeran & Burna Boy)", the credits section is as follows - Details under 'show Credits' section of the song

I'm trying to retrieve this info through python: :)

This information doesn't seem to be exposed in the spotify API: https://developer.spotify.com

So it seems like there is no way to get this information via a python-package that relies on the official API.

import requests
import json

# Set up the authentication parameters
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"

# Request an access token
response = requests.post("https://accounts.spotify.com/api/token",
                         data={
                            "grant_type": "client_credentials"
                         },
                         auth=(client_id, client_secret))

# Extract the access token from the response
access_token = json.loads(response.text)["access_token"]

# Set up the headers for the API request
headers = {
    "Authorization": f"Bearer {access_token}"
}

# Make the API request
track_id = "3n3Ppam7vgaVa1iaRUc9Lp"
response = requests.get(f"https://api.spotify.com/v1/tracks/{track_id}", headers=headers)

# Print the response
print(response.text)

This code snippet is just an example, you need to replace "YOUR_CLIENT_ID" and "YOUR_CLIENT_SECRET" with the actual values of your Spotify Web API client ID and secret, respectively. Also, this example retrieve the information of a specific track by providing its ID. Also, You can do more operations like search tracks, artists, albums, etc. in the Spotify Web API by using similar code and different endpoints. Please make sure you have read and understand the Spotify Web API's terms of use and developer policy before using it in any project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM