Python Soundcloud SDK上传

2024-06-08 15:02:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个调用soundcloud api的应用程序,在本例中使用pythonsoundcloudsdk(https://developers.soundcloud.com/docs/api/guide#uploading-files)上载一个曲目

我已经验证令牌是否有效,可以丢弃该案例,这是执行请求的代码:

import soundcloud
import sys, json

def uploadTrack(token, title, file):
  # create a client object with access token
  client = soundcloud.Client(access_token=token)

  # upload audio file
  track = client.post('/tracks', track={
    'title': title,
    'downloadable': 'true',
    'asset_data': open(file, 'rb')
  })

在结果回调中,我得到以下错误

^{2}$

但是,当我检查用户的soundcloud帐户时,该曲目出现在那里(成功上传)。在


Tags: httpsimportclienttokenapi应用程序accesstitle