Soundcloud轨道/下载slug不再有效

时间:2015-11-04 22:05:11

标签: soundcloud

Soundcloud具有允许任何曲目自动下载的功能,如果您添加" / download"到跟踪网址的末尾。

我们在soundcloud托管播客上使用了多年的功能:

http://techzinglive.com
http://soundcloud.com/techzing

截至几天前,该功能似乎已停止工作。

既然我们有300集,那么通过复制粘贴每集的下载链接就很难回头并回顾性地更改网址。

a)Soundcloud有什么方法可以解决这个问题吗?

b)是否存在做同样事情的替代方案?

示例:

168: TZ Interview - Patrick Collison / Stripe
~~~
http://soundcloud.com/techzing/techzing-168 (regular link)
http://soundcloud.com/techzing/techzing-168/download (auto download link)

注意:我是根据soundcloud支持页面的指示在此发布的。

1 个答案:

答案 0 :(得分:1)

问题的答案是SoundCloud不再支持下载slug选项。但是你可以使用他们的API来使用它。

后端(PHP)

<?php

    $yourSoundCloudClientId = '<CLIENTID>';
    $yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';

    if ( ! $trackData = json_decode(file_get_contents("http://api.soundcloud.com/resolve?url={$yourSoundCloudTrackUrl}&client_id={$yourSoundCloudClientId}")) )
    {
        die('Could not get the track because Soundcloud is down, or somethign else weird is happening.');
    }

    header("Location: {$trackData->download_url}?client_id={$yourSoundCloudClientId}");

?>

前端(JS)

<head>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://connect.soundcloud.com/sdk/sdk-3.0.0.js"></script>
<script>
var yourSoundCloudClientId = '<CLIENTID>';
var yourSoundCloudTrackUrl = 'http://soundcloud.com/techzing/techzing-001';
SC.initialize
({
    client_id: yourSoundCloudClientId
});
SC.get('/resolve?url='+yourSoundCloudTrackUrl).then
(
    function(track) 
    {
        $('#trackDiv').html('<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/'+track.id+'&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>');
    }
);
</script>
</head>
<body>
    <div id="trackDiv"></div>
</body>

原谅格式错误的HTML ......但是,你知道,它有效;)