如何通过代理服务器运行 youtube-dl

Shu*_*ena 15 proxy youtube-dl

我想通过代理服务器通过 youtube-dl 下载 youtube 视频,但它显示需要身份验证

代码:

http_proxy="http://username:password@proxy:port/" youtube-dl url
Run Code Online (Sandbox Code Playgroud)

它显示身份验证错误

min*_*ini 14

proxychains youtube-dl [options] LINK
Run Code Online (Sandbox Code Playgroud)

proxychans默认使用tor服务,如果您有自己的代理,请编辑/etc/proxychains.conf文件的最后一行。


sudo apt-get install proxychains tor obfsproxy
Run Code Online (Sandbox Code Playgroud)

如果要使用 tor,请将其配置为使用obfs2


net*_*ter 11

您可以对命令使用代理选项。

youtube-dl --proxy socks5://127.0.0.1:1080 url
Run Code Online (Sandbox Code Playgroud)

如果要为所有进一步调用使用代理,请创建一个配置文件

Linux/OSX:~/.config/youtube-dl/config

Windows:%APPDATA%\youtube-dl\config.txt

与内容

--proxy socks5://127.0.0.1:1080
Run Code Online (Sandbox Code Playgroud)


小智 6


对于当前版本的 youtube-dl,您可以使用 switch --proxy

例如
$youtube-dl --proxy http://user:password@your_proxy.com:port url

对我有用


小智 5

现在不推荐使用该调用语法。

从帮助页面:

--proxy URL                      Use the specified HTTP/HTTPS proxy. Pass in an empty string (--proxy "") for direct connection
--cn-verification-proxy URL      Use this proxy to verify the IP address for some Chinese sites. The default proxy specified by --proxy (or none, if the options is not present) is used for the actual downloading.
Run Code Online (Sandbox Code Playgroud)

所以除非你使用中文代理,否则命令应该是:

youtube-dl [OPTIONS] --proxy 'http(s)://PROXY_URL:PROXY_PORT' URL
Run Code Online (Sandbox Code Playgroud)

根据代理类型在 http 或 https 之间进行选择。

您也可以尝试直接使用 urllib2 测试您的代理:

#!/usr/bin/python
import urllib2
import sys
url = sys.argv[1]
response = urllib2.urlopen(url)
html_string = response.read()
print html_string
Run Code Online (Sandbox Code Playgroud)