Merge branch 'hjk41-socks' into develop

This commit is contained in:
Mort Yao 2016-07-21 15:55:02 +02:00
commit 1c40581fc7
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -1214,15 +1214,18 @@ def script_main(script_name, download, download_playlist, **kwargs):
if (socks_proxy): if (socks_proxy):
try: try:
import socket import socket
import socks import socks
socks_proxy_addrs = socks_proxy.split(':') socks_proxy_addrs = socks_proxy.split(':')
socks.set_default_proxy(socks.SOCKS5, socks.set_default_proxy(socks.SOCKS5,
socks_proxy_addrs[0], socks_proxy_addrs[0],
int(socks_proxy_addrs[1])) int(socks_proxy_addrs[1]))
socket.socket = socks.socksocket socket.socket = socks.socksocket
def getaddrinfo(*args):
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', (args[0], args[1]))]
socket.getaddrinfo = getaddrinfo
except ImportError: except ImportError:
log.w('Error importing PySocks library, socks proxy ignored.' log.w('Error importing PySocks library, socks proxy ignored.'
'In order to use use socks proxy, please install PySocks.') 'In order to use use socks proxy, please install PySocks.')
else: else:
import socket import socket