从每首歌曲获取HTTP MP3流 [英] Get HTTP MP3 stream from every song

查看:290
本文介绍了从每首歌曲获取HTTP MP3流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从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

然后使用

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或JavaScript将其转换为文件.

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

Sounddrain给了我这个URL:

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

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

解决方案

我认为这与您传递到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"
}

更多信息可以在此提交此问题.我不知道常规的client_id和iPhone client_id之间有什么区别,但是我可以清楚地看到API请求返回的区别.似乎iPhone client_id是SoundCloud iOS客户端用来在应用程序中流式播放曲目的API密钥.

I need to get the direct URL from a SoundCloud MP3 file.

I normally used the following method: Resolve the track URL to get the track id, e.g. using https://soundcloud.com/linkin_park/burn-it-down with

http://api.soundcloud.com/resolve.json?url=http://soundcloud.com/your/link/to/the/track&client_id=client_id

Then go for the stream_urls with

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

In most cases, the "http_128_mp3_url", the URL I need, is returned, which links directly to the MP3 of the song.

But in some cases, e.g. when you use https://soundcloud.com/dada-life/dada-life-september-2014-mix, only the rtmp or hls stream is returned, which I cannot convert to a file with PHP or JavaScript.

As seen on http://sounddrain.com/, there is a way to get the link for the MP3 file in this case too.

Sounddrain gives me this URL:

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

Has someone an idea how to get the following URL?

解决方案

I think this specifically has to do with the type of client_id you pass into the API request.

HTTP GET: http://api.soundcloud.com/i1/tracks/167132129/streams?client_id=[CLIENT_ID]

Using a standard application client_id, I don't see the http link:

Response:

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

However, using the youtube-dl iPhone client_id, the http url is returned:

Response:

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

More information can be found in this commit and this issue on the youtube-dl page. I don't know exactly what the difference is between a regular client_id and an iPhone client_id, but I can clearly see the difference in what is returned by the API request. It would appear that the iPhone client_id is the API key used by the SoundCloud iOS client to stream tracks in the app.

这篇关于从每首歌曲获取HTTP MP3流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆