简体   繁体   English

有没有办法在 Spotify 上提取歌曲/曲目的学分?

[英]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.我试图看看我是否可以从 spotify 轨道中提取信用部分的值(作者、制作者等)。

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.使用 Spotipy 库,有人告诉我有一个相同的 function,( track_info['songwriters']track_audio_features(trackid) )但它们不再工作了。

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在歌曲“Stormzy - Own It(Feat. Ed Sheeran & Burna Boy)”中,演职员表部分如下 -歌曲“显示演职员表”部分下的详细信息

I'm trying to retrieve this info through python: :)我正在尝试通过 python 检索此信息::)

This information doesn't seem to be exposed in the spotify API: https://developer.spotify.com 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.所以似乎没有办法通过依赖官方 API 的 python 包来获取这些信息。

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.此代码片段只是一个示例,您需要将“YOUR_CLIENT_ID”和“YOUR_CLIENT_SECRET”分别替换为您的 Spotify Web API 客户端 ID 和密码的实际值。 Also, this example retrieve the information of a specific track by providing its ID.此外,此示例通过提供其 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.此外,您可以通过使用类似的代码和不同的端点在 Spotify Web API 中执行更多操作,如搜索曲目、艺术家、专辑等。 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.在任何项目中使用之前,请确保您已阅读并理解 Spotify Web API 的使用条款和开发者政策。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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