Add support for SOCKS proxy (e.g. Tor)? #2444

Closed
opened 2026-02-21 00:22:13 -05:00 by deekerman · 6 comments
Owner

Originally created by @felixphew on GitHub (Jun 16, 2014).

I would like to use youtube-dl behind a transparent proxy at school. However, it can be restrictive and, worse still, it's not completely "transparent". So when I download a youtube video, it keeps returning a 7kb file that I assume is a redirection page. The same is true for most sites. With other programs I can sometimes circumvent this using TOR, but I am unable to do this with youtube-dl as it does not support SOCKS proxies. It also doesn't react well to wrappers (e.g. usewithtor, torsocks, torify, proxy chains etc.). Please add SOCKS support soon!

Originally created by @felixphew on GitHub (Jun 16, 2014). I would like to use youtube-dl behind a transparent proxy at school. However, it can be restrictive and, worse still, it's not completely "transparent". So when I download a youtube video, it keeps returning a 7kb file that I assume is a redirection page. The same is true for most sites. With other programs I can sometimes circumvent this using [TOR](https://torproject.org), but I am unable to do this with youtube-dl as it does not support SOCKS proxies. It also doesn't react well to wrappers (e.g. usewithtor, torsocks, torify, proxy chains etc.). Please add SOCKS support soon!
Author
Owner

@jaimeMF commented on GitHub (Jun 17, 2014):

I'm not a tor expert, but it seems that using torify youtube-dl ... works:

$ youtube-dl 'https://check.torproject.org/' --write-pages
[debug] System config: []
[debug] User config: ['--keep-video', '--write-info-json', '--write-thumbnail', '--verbose']
[debug] Command-line args: ['https://check.torproject.org/', '--write-pages']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2014.06.16
[debug] Git HEAD: b60a469
[debug] Python version 3.4.1 - Darwin-13.2.0-x86_64-i386-64bit
[debug] Proxy map: {}
[generic] check.torproject: Requesting header
WARNING: Falling back on generic information extractor.
[generic] check.torproject: Downloading webpage
[generic] Saving request to check.torproject_https_-_check.torproject.org_.dump
[generic] check.torproject: Extracting information
ERROR: Unsupported URL: https://check.torproject.org/; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type  youtube-dl -U  to update.
<ERROR DETAILS>

$ grep 'Tor' check.torproject_https_-_check.torproject.org_.dump
  <title>Are you using Tor?</title>
      Sorry. You are not using Tor.
      If you are attempting to use a Tor client, please refer to the <a href="https://www.torproject.org/">Tor website</a> and specifically the <a href="https://www.torproject.org/docs/faq#DoesntWork">instructions for configuring your Tor client</a>.
  <a id="donate" href="https://www.torproject.org/donate/donate.html">Donate to Support Tor</a>
      <a href="https://tor.stackexchange.com/">Tor Q&amp;A Site</a>
    <p class="project">The Tor Project is a US 501(c)(3) non-profit dedicated to the research, development, and education of online anonymity and privacy. <a href="https://www.torproject.org/about/overview.html.en">Learn More &raquo;</a></p>

$ torify youtube-dl 'https://check.torproject.org/' --write-pages
.... SAME AS BEFORE

$ grep 'Tor' check.torproject_https_-_check.torproject.org_.dump
  <title>Are you using Tor?</title>
      Congratulations. This browser is configured to use Tor.
            However, it does not appear to be the Tor Browser Bundle.<br />
      Please refer to the <a href="https://www.torproject.org/">Tor website</a> for further information about using Tor safely.  You are now free to browse the Internet anonymously. For more information about this exit relay, see: <a href="https://atlas.torproject.org/#details/<REMOVED>">Atlas</a>.
  <a id="donate" href="https://www.torproject.org/donate/donate.html">Donate to Support Tor</a>
      <a href="https://tor.stackexchange.com/">Tor Q&amp;A Site</a>
    <p class="project">The Tor Project is a US 501(c)(3) non-profit dedicated to the research, development, and education of online anonymity and privacy. <a href="https://www.torproject.org/about/overview.html.en">Learn More &raquo;</a></p>

Why do you say it doesn't work in your case?

There's already an issue about implementing SOCKS proxy support: #402.

@jaimeMF commented on GitHub (Jun 17, 2014): I'm not a tor expert, but it seems that using `torify youtube-dl ...` works: ``` $ youtube-dl 'https://check.torproject.org/' --write-pages [debug] System config: [] [debug] User config: ['--keep-video', '--write-info-json', '--write-thumbnail', '--verbose'] [debug] Command-line args: ['https://check.torproject.org/', '--write-pages'] [debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8 [debug] youtube-dl version 2014.06.16 [debug] Git HEAD: b60a469 [debug] Python version 3.4.1 - Darwin-13.2.0-x86_64-i386-64bit [debug] Proxy map: {} [generic] check.torproject: Requesting header WARNING: Falling back on generic information extractor. [generic] check.torproject: Downloading webpage [generic] Saving request to check.torproject_https_-_check.torproject.org_.dump [generic] check.torproject: Extracting information ERROR: Unsupported URL: https://check.torproject.org/; please report this issue on https://yt-dl.org/bug . Be sure to call youtube-dl with the --verbose flag and include its complete output. Make sure you are using the latest version; type youtube-dl -U to update. <ERROR DETAILS> $ grep 'Tor' check.torproject_https_-_check.torproject.org_.dump <title>Are you using Tor?</title> Sorry. You are not using Tor. If you are attempting to use a Tor client, please refer to the <a href="https://www.torproject.org/">Tor website</a> and specifically the <a href="https://www.torproject.org/docs/faq#DoesntWork">instructions for configuring your Tor client</a>. <a id="donate" href="https://www.torproject.org/donate/donate.html">Donate to Support Tor</a> <a href="https://tor.stackexchange.com/">Tor Q&amp;A Site</a> <p class="project">The Tor Project is a US 501(c)(3) non-profit dedicated to the research, development, and education of online anonymity and privacy. <a href="https://www.torproject.org/about/overview.html.en">Learn More &raquo;</a></p> $ torify youtube-dl 'https://check.torproject.org/' --write-pages .... SAME AS BEFORE $ grep 'Tor' check.torproject_https_-_check.torproject.org_.dump <title>Are you using Tor?</title> Congratulations. This browser is configured to use Tor. However, it does not appear to be the Tor Browser Bundle.<br /> Please refer to the <a href="https://www.torproject.org/">Tor website</a> for further information about using Tor safely. You are now free to browse the Internet anonymously. For more information about this exit relay, see: <a href="https://atlas.torproject.org/#details/<REMOVED>">Atlas</a>. <a id="donate" href="https://www.torproject.org/donate/donate.html">Donate to Support Tor</a> <a href="https://tor.stackexchange.com/">Tor Q&amp;A Site</a> <p class="project">The Tor Project is a US 501(c)(3) non-profit dedicated to the research, development, and education of online anonymity and privacy. <a href="https://www.torproject.org/about/overview.html.en">Learn More &raquo;</a></p> ``` Why do you say it doesn't work in your case? There's already an issue about implementing SOCKS proxy support: #402.
Author
Owner

@felixphew commented on GitHub (Jun 17, 2014):

I'm on OS X and so I compiled tor and torsocks (which is the backend to torify) myself, but I didn't do such a great job, and so my torify/torsocks/usewithtor only work about half the time. I know this is a problem at my end, not yours, but SOCKS support would be great anyway.

@felixphew commented on GitHub (Jun 17, 2014): I'm on OS X and so I compiled `tor` and `torsocks` (which is the backend to `torify`) myself, but I didn't do such a great job, and so my `torify`/`torsocks`/`usewithtor` only work about half the time. I know this is a problem at my end, not yours, but SOCKS support would be great anyway.
Author
Owner

@vedharish commented on GitHub (Jun 18, 2014):

Works with proxychains as well.
Just chain it to the tor proxy.

@vedharish commented on GitHub (Jun 18, 2014): Works with <a href="http://proxychains.sourceforge.net/">proxychains</a> as well. Just chain it to the tor proxy.
Author
Owner

@jaimeMF commented on GitHub (Jun 18, 2014):

You can use a package manager (like Hombrew) to install tor.
I'm closing this issue in favour of the old one.

@jaimeMF commented on GitHub (Jun 18, 2014): You can use a package manager (like [Hombrew](https://github.com/Homebrew/homebrew)) to install tor. I'm closing this issue in favour of the old one.
Author
Owner

@moshpirit commented on GitHub (Aug 16, 2015):

┌─ alberto manjaro  ~ 
└──┤|▶ torify youtube-dl 'https://check.torproject.org/' --write-pages
[generic] check.torproject: Requesting header
[Aug 16 18:37:21] PERROR torsocks[3160]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:185)
WARNING: Could not send HEAD request to https://check.torproject.org/: <urlopen error [Errno -4] Non-recoverable failure in name resolution>
[generic] check.torproject: Downloading webpage
[Aug 16 18:37:21] PERROR torsocks[3160]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:185)
ERROR: Unable to download webpage: <urlopen error [Errno -4] Non-recoverable failure in name resolution> (caused by URLError(gaierror(-4, 'Non-recoverable failure in name resolution'),))

Am I doing anything wrong? it could be really cool to add youtube-dl -tor as another option

@moshpirit commented on GitHub (Aug 16, 2015): ``` ┌─ alberto manjaro ~ └──┤|▶ torify youtube-dl 'https://check.torproject.org/' --write-pages [generic] check.torproject: Requesting header [Aug 16 18:37:21] PERROR torsocks[3160]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:185) WARNING: Could not send HEAD request to https://check.torproject.org/: <urlopen error [Errno -4] Non-recoverable failure in name resolution> [generic] check.torproject: Downloading webpage [Aug 16 18:37:21] PERROR torsocks[3160]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:185) ERROR: Unable to download webpage: <urlopen error [Errno -4] Non-recoverable failure in name resolution> (caused by URLError(gaierror(-4, 'Non-recoverable failure in name resolution'),)) ``` Am I doing anything wrong? it could be really cool to add `youtube-dl -tor` as another option
Author
Owner

@yxliang01 commented on GitHub (Apr 15, 2017):

when connecting to google services, won't tor connections need a captcha?

@yxliang01 commented on GitHub (Apr 15, 2017): when connecting to google services, won't tor connections need a captcha?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#2444
No description provided.