我需要从SoundCloud MP3文件中获取直接网址。
我通常使用以下方法: 解析曲目网址以获取曲目ID,例如使用https://soundcloud.com/linkin_park/burn-it-down和
http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/your/link/to/the/track&client_id=client_id
然后使用
转到stream_urlshttp://api.sndcdn.com/i1/tracks/track_id_here/streams?client_id=client_id
在大多数情况下,返回" http_128_mp3_url",我需要的URL,它直接链接到歌曲的MP3。
但在某些情况下,例如当你使用https://soundcloud.com/dada-life/dada-life-september-2014-mix时,只返回rtmp或hls流,我无法将其转换为PHP或JavaScript文件。
如http://sounddrain.com/所示,在这种情况下,有一种方法可以获取MP3文件的链接。
Sounddrain给了我这个网址:
有人知道如何获取以下网址吗?
答案 0 :(得分:9)
我认为这与您传递给API请求的client_id类型有关。
HTTP GET: http://api.soundcloud.com/i1/tracks/167132129/streams?client_id=[CLIENT_ID]
使用标准应用程序client_id,我看不到http链接:
响应:
{
"hls_mp3_128_url": "https://ec-hls-media.soundcloud.com/playlist/KZ5qiLqZ0OSk.128.mp3/playlist.m3u8?f10880d39085a94a0418a7e062b03d52bbdc0e179b82bde1d76ce7a51e4e690d4aa9adbb8e264aa259bfba6e1a3d52e8f8020eeb45fac9d9fbb175e4c35dbd26bdf59ac00d0f2cd80b7e7a685e9cd57c89622a7cc8b7266f4b7317b4",
"rtmp_mp3_128_url": "rtmp://ec-rtmp-media.soundcloud.com/mp3:KZ5qiLqZ0OSk.128?9527d18f1063a01f059bf10590159adb10dea0996b8c0cdb674f9c282214839d8263f0608a1a3bbe02e4a0ffc5cf5bef80087ca63aa316e338f6cbba24b1493d8355aea84dc2e529757f72273e1fdfc9f88437c992e92845b3e3",
"preview_mp3_128_url": "https://ec-preview-media.sndcdn.com/preview/0/90/KZ5qiLqZ0OSk.128.mp3?f10880d39085a94a0418a7e162b03d52e21adf826af17a391e1b741835259dfd645b4f9f979acc1e4d50dd281c2b93dca58d9e3bd086be0aed9c5ae0ae369364f50bd63ee4f1b167cc29b19cf3462f735b8f"
}
但是,使用youtube-dl iPhone client_id,将返回http url:
响应:
{
"http_mp3_128_url": "https://ec-media.sndcdn.com/KZ5qiLqZ0OSk.128.mp3?f10880d39085a94a0418a7ef69b03d522cd6dfee9399eeb9a522029c69f0bd356988380857d739f55360e9ce802160a1ecf506cfa53f249070d96b19de5ac3234cdbd4201d",
"hls_mp3_128_url": "https://ec-hls-media.soundcloud.com/playlist/KZ5qiLqZ0OSk.128.mp3/playlist.m3u8?f10880d39085a94a0418a7e062b03d52bbdc0e179b82bde1d76ce7a51e4e6e074a18d603fc2146725c4f70a8844d81268632e8339ce8b52aab8fcfbfd450330b409e8614da1996b8e4cd371f07c9eb0d5cc65ffbf60230336388b323",
"rtmp_mp3_128_url": "rtmp://ec-rtmp-media.soundcloud.com/mp3:KZ5qiLqZ0OSk.128?9527d18f1063a01f059bf10590159adb10dea0996b8c0cdb674f9c28221b8a972788cc587dee254b285c2a0c9e5b57a79b4bd174401f92b31df0cf4260d9f3f6fe542e181d30b4e9314ac36e70737095ddb2b215bd98884660cb",
"preview_mp3_128_url": "https://ec-preview-media.sndcdn.com/preview/0/90/KZ5qiLqZ0OSk.128.mp3?f10880d39085a94a0418a7e162b03d52e21adf826af17a391e1b7418352a94f7cbd4ec4b06d76ae6caf6f3cc29aed3f7b0922885d994c71a503c307cf86b653b3f6108990bebaae5a15efc74075285b13f23"
}
可以在youtube-dl页面的this commit和this issue中找到更多信息。我不确切知道常规client_id和iPhone client_id之间有什么区别,但我可以清楚地看到API请求返回的内容之间的差异。 iPhone client_id似乎是SoundCloud iOS客户端用来在应用程序中流式传输曲目的API密钥。
答案 1 :(得分:0)
soundcloud将所有上传内容重新编码为128k mp3以进行流式播放。只要您启用了流媒体并且该曲目是公开的,您只需要
https://api.soundcloud.com/tracks/TRACKID/stream?client_id=CLIENTID