przemyslawpluta / node-youtube-dl

youtube-dl driver for node
MIT License
1.71k stars 368 forks source link

Proxy Support #38

Closed untergrundbiber closed 10 years ago

untergrundbiber commented 10 years ago

Hi there

I work on a script to download YT videos, that are blocked in my country, over an ssh-tunnled proxy. I tried your example download script with the option "--proxy=127.0.0.1:8000", but it throws an error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: status code 403
    at Request.<anonymous> (/root/nodejs/node_modules/youtube-dl/lib/youtube-dl.js:65:30)
    at Request.EventEmitter.emit (events.js:95:17)
    at Request.onResponse (/root/nodejs/node_modules/youtube-dl/node_modules/request/request.js:924:10)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1583:20)
    at CleartextStream.read [as _read] (tls.js:511:12)
    at CleartextStream.Readable.read (_stream_readable.js:320:10)

When i call youtube-dl from the console it works flawless. "youtube-dl --proxy http://127.0.0.1:8000/ https://www.youtube.com/watch?v=Lle-q-0SL_c"

Would it be possible to implant proxy support?

Greetings

fent commented 10 years ago

Does it work without the proxy?

untergrundbiber commented 10 years ago

Yes, without proxy i have no problems.

fent commented 10 years ago

Can you try prepending the proxy address with http://. Also can you try separating it into two strings, --proxy and http://127.0.0.1:8000/

untergrundbiber commented 10 years ago

I would really like to test but with the new version 1.5.9 I also have a new problem. This error occurs regardless of whether with or without proxy.

/root/ytdl_nodejs/node_modules/youtube-dl/lib/youtube-dl.js:109
      if (!options.nosubs && isNoSubsRegex.test(stderr)) {
                  ^
TypeError: Cannot read property 'nosubs' of undefined
    at /root/ytdl_nodejs/node_modules/youtube-dl/lib/youtube-dl.js:109:19
    at ChildProcess.exithandler (child_process.js:635:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
fent commented 10 years ago

Sorry about that, should be good now.

untergrundbiber commented 10 years ago

Sorry, next error :( I only install youtube-dl over npm, without any changes and execute your example-script.

~/ytjs/node_modules/youtube-dl/example # node download.js

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: : video doesn't have subtitles
WARNING: video doesn't have subtitles

    at /root/ytjs/node_modules/youtube-dl/lib/youtube-dl.js:125:23
    at ChildProcess.exithandler (child_process.js:635:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
fent commented 10 years ago

Are you running the exact file in the example dir? I just ran it and it downloaded fine.

untergrundbiber commented 10 years ago

Yes, install with "npm install youtube-dl" and run it in the example-dir

fent commented 10 years ago

I just did that, same result.

untergrundbiber commented 10 years ago

Ahh i'm so sorry, i forgot that i have a regular installed youtube-dl with a config (/etc/youtube-dl.conf) that download all subs. Sorry! I tested it now on another machine with fresh youtube-dl and it works. :+1:

And now the tests with proxy: I used the example download.js and change the the video-variable.

var video = ytdl('http://www.youtube.com/watch?v=Lle-q-0SL_c',['--proxy=http://127.0.0.1:8000/']);

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: status code 403
    at Request.<anonymous> (/home/synctube/ytjs/node_modules/youtube-dl/lib/youtube-dl.js:51:30)
    at Request.EventEmitter.emit (events.js:95:17)
    at Request.onResponse (/home/synctube/ytjs/node_modules/youtube-dl/node_modules/request/request.js:958:10)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1583:20)
    at CleartextStream.read [as _read] (tls.js:511:12)
    at CleartextStream.Readable.read (_stream_readable.js:320:10)

and without equal sign: var video = ytdl('http://www.youtube.com/watch?v=Lle-q-0SL_c',['--proxy http://127.0.0.1:8000/']);

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Command failed: Usage: youtube-dl [options] url [url...]

youtube-dl: error: no such option: --proxy http://127.0.0.1:8000/

    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Process.ChildProcess._handle.onexit (child_process.js:810:5)
fent commented 10 years ago

Hmm, I'm not sure how I can test this myself. Is there a proxy service somewhere I can use to test?

untergrundbiber commented 10 years ago

Yes, you can use one of these proxies: http://proxylist.hidemyass.com/#listable

or you use Tinyproxy and make your own local proxy, i think it makes no difference https://banu.com/tinyproxy/

fent commented 10 years ago

Ok. I just tried it by separating the option into two strings and it worked. Try this

var video = ytdl('http://www.youtube.com/watch?v=Lle-q-0SL_c',['--proxy', 'http://127.0.0.1:8000/']);
untergrundbiber commented 10 years ago

Wow, that works! Thank you so much! :+1: :+1: :+1:

fent commented 10 years ago

np.