一尘不染

从每首歌曲获取HTTP MP3流

json

我需要从SoundCloud MP3文件中获取直接URL。

我通常使用以下方法:解析轨道URL以获取轨道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_urls

http://api.sndcdn.com/i1/tracks/track_id_here/streams?client_id=client_id

在大多数情况下,将返回我需要的URL“ http_128_mp3_url”,该URL直接链接到歌曲的MP3。

但是在某些情况下,例如,当您使用https://soundcloud.com/dada-life/dada-life-
september-2014-mix时,仅返回rtmp或hls流,我无法使用PHP或PHP将其转换为文件JavaScript。

http://sounddrain.com/所示,在这种情况下,也有一种方法可以获取MP3文件的链接。

Sounddrain给了我这个URL:

https://ec-
media.sndcdn.com/KZ5qiLqZ0OSk.128.mp3?f10880d39085a94a0418a7ef69b03d522cd6dfee9399eeb9a522029c6df9ba3f0cf21c0c0c9d9baf9fe2d9aa920d344c36db47817da7597

有人知道如何获取以下网址吗?


阅读 600

收藏
2020-07-27

共1个答案

一尘不染

我认为这与您传递到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网址:

响应:

{
    "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"
}

可以在commit和youtube-
dl页面上的本期中找到更多信息。我不知道常规的client_id和iPhone
client_id之间有什么区别,但是我可以清楚地看到API请求返回的区别。看起来iPhone client_id是SoundCloud
iOS客户端用来在应用程序中流式播放曲目的API密钥。

2020-07-27