mirror of
https://github.com/soimort/you-get.git
synced 2025-01-24 05:55: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.
|
-x | --http-proxy <HOST:PORT> Use an HTTP proxy for downloading.
|
||||||
-y | --extractor-proxy <HOST:PORT> Use an HTTP proxy for extracting only.
|
-y | --extractor-proxy <HOST:PORT> Use an HTTP proxy for extracting only.
|
||||||
--no-proxy Never use a proxy.
|
--no-proxy Never use a proxy.
|
||||||
|
-s | --socks-proxy <HOST:PORT> Use an SOCKS5 proxy for downloading.
|
||||||
-t | --timeout <SECONDS> Set socket timeout.
|
-t | --timeout <SECONDS> Set socket timeout.
|
||||||
-d | --debug Show traceback and other debug info.
|
-d | --debug Show traceback and other debug info.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
short_opts = 'Vhfiuc:ndF:O:o:p:x:y:t:'
|
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=', 'extractor-proxy=', 'lang=', 'timeout=']
|
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:
|
if download_playlist:
|
||||||
short_opts = 'l' + short_opts
|
short_opts = 'l' + short_opts
|
||||||
opts = ['playlist'] + opts
|
opts = ['playlist'] + opts
|
||||||
@ -1104,6 +1105,7 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
|||||||
lang = None
|
lang = None
|
||||||
output_dir = '.'
|
output_dir = '.'
|
||||||
proxy = None
|
proxy = None
|
||||||
|
socks_proxy = None
|
||||||
extractor_proxy = None
|
extractor_proxy = None
|
||||||
traceback = False
|
traceback = False
|
||||||
timeout = 600
|
timeout = 600
|
||||||
@ -1176,6 +1178,8 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
|||||||
caption = False
|
caption = False
|
||||||
elif o in ('-x', '--http-proxy'):
|
elif o in ('-x', '--http-proxy'):
|
||||||
proxy = a
|
proxy = a
|
||||||
|
elif o in ('-s', '--socks-proxy'):
|
||||||
|
socks_proxy = a
|
||||||
elif o in ('-y', '--extractor-proxy'):
|
elif o in ('-y', '--extractor-proxy'):
|
||||||
extractor_proxy = a
|
extractor_proxy = a
|
||||||
elif o in ('--lang',):
|
elif o in ('--lang',):
|
||||||
@ -1189,6 +1193,20 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
|||||||
print(help)
|
print(help)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
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)
|
set_http_proxy(proxy)
|
||||||
|
|
||||||
socket.setdefaulttimeout(timeout)
|
socket.setdefaulttimeout(timeout)
|
||||||
|
Loading…
Reference in New Issue
Block a user