jbrooksuk / SoundRain

Evented Node.js module for downloading songs from SoundCloud.
19 stars 7 forks source link

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

Open l4j3b opened 10 years ago

l4j3b commented 10 years ago

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

jbrooksuk commented 10 years ago

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

jbrooksuk commented 10 years ago

FYI, I do have plans to do this too.

l4j3b commented 10 years ago

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.

jbrooksuk commented 10 years ago

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

l4j3b commented 10 years ago

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

jbrooksuk commented 10 years ago

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 commented 10 years ago

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

l4j3b commented 10 years ago

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 commented 10 years ago

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

jbrooksuk commented 10 years ago

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

l4j3b commented 10 years ago

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 :)

jbrooksuk commented 10 years ago

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

l4j3b commented 10 years ago

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

You are welcome, it was fun !