简体   繁体   English

如何获取在Python中发布到Soundcloud的轨道的秘密链接?

[英]How can I get the secret link for a track posted to Soundcloud in Python?

I'm developing a simple app using Python where I can post tracks to my own Soundcloud account. 我正在使用Python开发一个简单的应用程序,我可以将曲目发布到我自己的Soundcloud帐户。 I would like to get the 'Secret link' URL for a track that I post. 我想获得我发布的曲目的“秘密链接”网址。 For example, I get the most recent track like so: 例如,我得到了最新的曲目:

track = client.get('/me/tracks', limit=1)[0]

The track is set to private. 该轨道设置为私人。 It suggests in the Docs that something like this should return the secret token: 它在文档中建议这样的东西应该返回秘密令牌:

client.get('/tracks/%d/secret-token' %track.id)

However, I get HTTPError: 404 Client Error: Not Found. 但是,我得到HTTPError:404客户端错误:未找到。 All the other subresources seem to work. 所有其他子资源似乎都有效。 This example code, for example, works as you would expect: 例如,此示例代码可以按预期工作:

comments = client.get('/tracks/%d/comments' %track.id)

for comment in comments:
    print comment.body

I would have thought that, given that I have authenticated using my credentials, I would have access to this. 我原以为,鉴于我已经使用我的凭据进行了身份验证,我可以访问它。 Is this correct? 这个对吗? Any assistance would be greatly appreciated. 任何帮助将不胜感激。

The /me/tracks endpoint returns a Track object that includes secret_token as well as the full uri secret_uri . / me / tracks端点返回一个Track对象,其中包含secret_token以及完整的uri secret_uri

track = client.get('/me/tracks', limit=1)[0]
print "Secret Token: %s" %track.secret_token
print "Track URI: %s"  %track.secret_uri

I found I needed to include the client_id in the URI to avoid getting a 401. 我发现我需要在URI中包含client_id以避免获得401。

Note: this is undocumented so check with their support team before relying this in an application 注意:这是未记录的,因此请先与其支持团队联系,然后再将其依赖于应用程序

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

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