SoundRain icon indicating copy to clipboard operation
SoundRain copied to clipboard

Does not work for some files, "TypeError: Cannot read property 'protocol' of undefined"

Open l4j3b opened this issue 11 years ago • 13 comments

Hi,

I tried soundscrape with the following file:

https://soundcloud.com/yellowclaw/major-lazer-jah-no-partial

command: soundscrape yellowclaw major-lazer-jah-no-partial

And get the following error:

http.js:1839 if (options.protocol && options.protocol !== 'http:') { ^ TypeError: Cannot read property 'protocol' of undefined at Object.exports.request (http.js:1839:14) at Object.exports.get (http.js:1847:21) at ClientRequest. (/usr/local/lib/node_modules/soundscrape/soundscrape.coffee:77:19) at ClientRequest.g (events.js:175:14) at ClientRequest.EventEmitter.emit (events.js:95:17) at HTTPParser.parserOnIncomingClient as onIncoming at HTTPParser.parserOnHeadersComplete as onHeadersComplete at Socket.socketOnData as ondata at TCP.onread (net.js:525:27)

I tried to investigate but did not find anything... The only issue that could have been relate seems to have been fixed (nodejitsu/node-http-proxy#499).

Any ideas?

Thanks,

Edouard

l4j3b avatar Jan 02 '14 17:01 l4j3b

Ah, it only works with HTTP connections. Try http://soundcloud.com/yellowclaw/major-lazer-jah-no-partial

jbrooksuk avatar Jan 02 '14 19:01 jbrooksuk

FYI, I do have plans to do this too.

jbrooksuk avatar Jan 02 '14 19:01 jbrooksuk

Thanks for the answer ! :)

I tried using http too, but did not work. I think it may be a problem with http.js...

Plans to do what?

EDIT: Just noticed I said soundscrape in my first post. I tested with it too and had the same issue.

l4j3b avatar Jan 02 '14 19:01 l4j3b

Interesting... I expected it to work with HTTP. I'll investigate.

jbrooksuk avatar Jan 02 '14 19:01 jbrooksuk

I think it may be related to node http itself and not your code...

l4j3b avatar Jan 02 '14 19:01 l4j3b

Yeah... I'm starting to think that too, even links that used to work have stopped. I wonder if they've changed the format.

jbrooksuk avatar Jan 02 '14 19:01 jbrooksuk

Ok, it seems that all SoundCloud downloaders have stopped working.

jbrooksuk avatar Jan 02 '14 20:01 jbrooksuk

I was looking at the http.js file (where http.get is defined).

line 1836:

exports.request = function(options, cb) { if (typeof options === 'string') { options = url.parse(options); } ... }

It probably means the problem is that the URL is not recognized as a string and options considered as an object...

l4j3b avatar Jan 02 '14 20:01 l4j3b

So, basically, it looks like the streamUrl uses a different protocol, RTMP.

The json returned by the call on /streams is like {"rtmp_mp3_128_url":"rtmp://ec-rtmp-med....

instead of {"http_mp3_128_url":"https://ec-media.s...

So basically, some tracks are using the RTMP protocol. It should be easy to fix https://npmjs.org/package/rtmp-download

I will try to monkey patch my copy.

EDIT: the tricky part is now to get the RTMP url, it is not present in the html response from the track URL

l4j3b avatar Jan 02 '14 22:01 l4j3b

How can a string just magically be turned into an object though?

jbrooksuk avatar Jan 03 '14 08:01 jbrooksuk

Disregard the comment about that, the problem is just that protocol RTMP...

I ended up finding and using that: https://github.com/rg3/youtube-dl

easier...

Thanks for the answer though, I really appreciate it :)

l4j3b avatar Jan 03 '14 08:01 l4j3b

Does that do SoundCloud? I'll look at integrating RTMP when I get a bit of spare time. Thanks for helping me debug this!

jbrooksuk avatar Jan 03 '14 08:01 jbrooksuk

Yes, it does soundcloud. You can probably look at their code to find the solution :)

You are welcome, it was fun !

l4j3b avatar Jan 03 '14 08:01 l4j3b