mirror of
https://github.com/soimort/you-get.git
synced 2025-02-03 08:43:58 +03:00
[common]add -I --input-file flag
This commit is contained in:
parent
86493087d4
commit
0a8f708c31
@ -1184,13 +1184,15 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
-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.
|
||||
-I | --input-file Read non-playlist urls from file.
|
||||
'''
|
||||
|
||||
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
|
||||
short_opts = 'Vhfiuc:ndF:O:o:p:x:y:s:t:I:'
|
||||
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=', 'input-file=']
|
||||
#dead code? download_playlist is a function and always True
|
||||
#if download_playlist:
|
||||
short_opts = 'l' + short_opts
|
||||
opts = ['playlist'] + opts
|
||||
|
||||
try:
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], short_opts, opts)
|
||||
@ -1219,6 +1221,8 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
extractor_proxy = None
|
||||
traceback = False
|
||||
timeout = 600
|
||||
urls_from_file = []
|
||||
|
||||
for o, a in opts:
|
||||
if o in ('-V', '--version'):
|
||||
version()
|
||||
@ -1296,12 +1300,23 @@ def script_main(script_name, download, download_playlist, **kwargs):
|
||||
lang = a
|
||||
elif o in ('-t', '--timeout'):
|
||||
timeout = int(a)
|
||||
elif o in ('-I', '--input-file'):
|
||||
logging.debug('you are trying to load urls from {}'.format(a))
|
||||
if playlist:
|
||||
log.e("reading playlist from a file is unsupported and won't make your life easier")
|
||||
sys.exit(2)
|
||||
with open(a, 'r') as input_file:
|
||||
for line in input_file:
|
||||
url = line.strip()
|
||||
urls_from_file.append(url)
|
||||
else:
|
||||
log.e("try 'you-get --help' for more options")
|
||||
sys.exit(2)
|
||||
if not args:
|
||||
if not args and not urls_from_file:
|
||||
print(help)
|
||||
sys.exit()
|
||||
args.extend(urls_from_file)
|
||||
print(args)
|
||||
|
||||
if (socks_proxy):
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user