mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
Merge branch 'hjk41-develop' into develop (close #1046)
This commit is contained in:
commit
7c2ea4f641
@ -1071,12 +1071,13 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
-x | --http-proxy <HOST:PORT> Use an HTTP proxy for downloading.
|
||||
-y | --extractor-proxy <HOST:PORT> Use an HTTP proxy for extracting only.
|
||||
--no-proxy Never use a proxy.
|
||||
-s | --socks-proxy <HOST:PORT> Use an SOCKS5 proxy for downloading.
|
||||
-t | --timeout <SECONDS> Set socket timeout.
|
||||
-d | --debug Show traceback and other debug info.
|
||||
'''
|
||||
|
||||
short_opts = 'Vhfiuc:ndF:O:o:p:x:y:t:'
|
||||
opts = ['version', 'help', 'force', 'info', 'url', 'cookies', 'no-caption', 'no-merge', 'no-proxy', 'debug', 'json', 'format=', 'stream=', 'itag=', 'output-filename=', 'output-dir=', 'player=', 'http-proxy=', 'extractor-proxy=', 'lang=', 'timeout=']
|
||||
short_opts = 'Vhfiuc:ndF:O:o:p:x:y:s:t:'
|
||||
opts = ['version', 'help', 'force', 'info', 'url', 'cookies', 'no-caption', 'no-merge', 'no-proxy', 'debug', 'json', 'format=', 'stream=', 'itag=', 'output-filename=', 'output-dir=', 'player=', 'http-proxy=', 'socks-proxy=', 'extractor-proxy=', 'lang=', 'timeout=']
|
||||
if download_playlist:
|
||||
short_opts = 'l' + short_opts
|
||||
opts = ['playlist'] + opts
|
||||
@ -1104,6 +1105,7 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
lang = None
|
||||
output_dir = '.'
|
||||
proxy = None
|
||||
socks_proxy = None
|
||||
extractor_proxy = None
|
||||
traceback = False
|
||||
timeout = 600
|
||||
@ -1176,6 +1178,8 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
caption = False
|
||||
elif o in ('-x', '--http-proxy'):
|
||||
proxy = a
|
||||
elif o in ('-s', '--socks-proxy'):
|
||||
socks_proxy = a
|
||||
elif o in ('-y', '--extractor-proxy'):
|
||||
extractor_proxy = a
|
||||
elif o in ('--lang',):
|
||||
@ -1189,7 +1193,21 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
print(help)
|
||||
sys.exit()
|
||||
|
||||
set_http_proxy(proxy)
|
||||
if (socks_proxy):
|
||||
try:
|
||||
import socket
|
||||
import socks
|
||||
socks_proxy_addrs = socks_proxy.split(':')
|
||||
socks.set_default_proxy(socks.SOCKS5,
|
||||
socks_proxy_addrs[0],
|
||||
int(socks_proxy_addrs[1]))
|
||||
socket.socket = socks.socksocket
|
||||
except ImportError:
|
||||
log.w('Error importing PySocks library, socks proxy ignored.'
|
||||
'In order to use use socks proxy, please install PySocks.')
|
||||
else:
|
||||
import socket
|
||||
set_http_proxy(proxy)
|
||||
|
||||
socket.setdefaulttimeout(timeout)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user