mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 21:45:02 +03:00
Merge branch 'new-features' of https://github.com/radaiming/you-get into radaiming-new-features
This commit is contained in:
commit
627209b149
@ -15,6 +15,7 @@ from .util import log, legitimize, sogou_proxy_server
|
|||||||
|
|
||||||
dry_run = False
|
dry_run = False
|
||||||
force = False
|
force = False
|
||||||
|
player = None
|
||||||
sogou_proxy = None
|
sogou_proxy = None
|
||||||
sogou_env = None
|
sogou_env = None
|
||||||
|
|
||||||
@ -78,6 +79,11 @@ def match1(text, *patterns):
|
|||||||
ret.append(match.group(1))
|
ret.append(match.group(1))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def launch_player(player, urls):
|
||||||
|
import subprocess
|
||||||
|
import shlex
|
||||||
|
subprocess.call(shlex.split(player) + list(urls))
|
||||||
|
|
||||||
def parse_query_param(url, param):
|
def parse_query_param(url, param):
|
||||||
"""Parses the query string of a URL and returns the value of a parameter.
|
"""Parses the query string of a URL and returns the value of a parameter.
|
||||||
|
|
||||||
@ -504,6 +510,10 @@ def download_urls(urls, title, ext, total_size, output_dir = '.', refer = None,
|
|||||||
print('Real URLs:\n', urls, '\n')
|
print('Real URLs:\n', urls, '\n')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if player:
|
||||||
|
launch_player(player, urls)
|
||||||
|
return
|
||||||
|
|
||||||
if not total_size:
|
if not total_size:
|
||||||
try:
|
try:
|
||||||
total_size = urls_size(urls)
|
total_size = urls_size(urls)
|
||||||
@ -587,6 +597,10 @@ def download_urls_chunked(urls, title, ext, total_size, output_dir = '.', refer
|
|||||||
print('Real URLs:\n', urls, '\n')
|
print('Real URLs:\n', urls, '\n')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if player:
|
||||||
|
launch_player(player, urls)
|
||||||
|
return
|
||||||
|
|
||||||
assert ext in ('ts')
|
assert ext in ('ts')
|
||||||
|
|
||||||
title = legitimize(title)
|
title = legitimize(title)
|
||||||
@ -792,6 +806,7 @@ def script_main(script_name, download, download_playlist = None):
|
|||||||
-u | --url Display the real URLs of videos without downloading.
|
-u | --url Display the real URLs of videos without downloading.
|
||||||
-n | --no-merge Don't merge video parts.
|
-n | --no-merge Don't merge video parts.
|
||||||
-o | --output-dir <PATH> Set the output directory for downloaded videos.
|
-o | --output-dir <PATH> Set the output directory for downloaded videos.
|
||||||
|
-p | --player <PLAYER [options]> Directly play the video with PLAYER like vlc/smplayer
|
||||||
-x | --http-proxy <HOST:PORT> Use specific HTTP proxy for downloading.
|
-x | --http-proxy <HOST:PORT> Use specific HTTP proxy for downloading.
|
||||||
--no-proxy Don't use any proxy. (ignore $http_proxy)
|
--no-proxy Don't use any proxy. (ignore $http_proxy)
|
||||||
-S | --sogou Use a Sogou proxy server for downloading.
|
-S | --sogou Use a Sogou proxy server for downloading.
|
||||||
@ -799,8 +814,8 @@ def script_main(script_name, download, download_playlist = None):
|
|||||||
--debug Show traceback on KeyboardInterrupt.
|
--debug Show traceback on KeyboardInterrupt.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
short_opts = 'VhfiunSo:x:'
|
short_opts = 'VhfiunSo:p:x:'
|
||||||
opts = ['version', 'help', 'force', 'info', 'url', 'no-merge', 'no-proxy', 'debug', 'sogou', 'output-dir=', 'http-proxy=', 'sogou-proxy=', 'sogou-env=']
|
opts = ['version', 'help', 'force', 'info', 'url', 'no-merge', 'no-proxy', 'debug', 'sogou', 'output-dir=', 'player=', 'http-proxy=', 'sogou-proxy=', 'sogou-env=']
|
||||||
if download_playlist:
|
if download_playlist:
|
||||||
short_opts = 'l' + short_opts
|
short_opts = 'l' + short_opts
|
||||||
opts = ['playlist'] + opts
|
opts = ['playlist'] + opts
|
||||||
@ -814,6 +829,7 @@ def script_main(script_name, download, download_playlist = None):
|
|||||||
|
|
||||||
global force
|
global force
|
||||||
global dry_run
|
global dry_run
|
||||||
|
global player
|
||||||
global sogou_proxy
|
global sogou_proxy
|
||||||
global sogou_env
|
global sogou_env
|
||||||
|
|
||||||
@ -841,19 +857,21 @@ def script_main(script_name, download, download_playlist = None):
|
|||||||
playlist = True
|
playlist = True
|
||||||
elif o in ('-n', '--no-merge'):
|
elif o in ('-n', '--no-merge'):
|
||||||
merge = False
|
merge = False
|
||||||
elif o in ('--no-proxy'):
|
elif o in ('--no-proxy',):
|
||||||
proxy = ''
|
proxy = ''
|
||||||
elif o in ('--debug'):
|
elif o in ('--debug',):
|
||||||
traceback = True
|
traceback = True
|
||||||
elif o in ('-o', '--output-dir'):
|
elif o in ('-o', '--output-dir'):
|
||||||
output_dir = a
|
output_dir = a
|
||||||
|
elif o in ('-p', '--player'):
|
||||||
|
player = a
|
||||||
elif o in ('-x', '--http-proxy'):
|
elif o in ('-x', '--http-proxy'):
|
||||||
proxy = a
|
proxy = a
|
||||||
elif o in ('-S', '--sogou'):
|
elif o in ('-S', '--sogou'):
|
||||||
sogou_proxy = ("0.0.0.0", 0)
|
sogou_proxy = ("0.0.0.0", 0)
|
||||||
elif o in ('--sogou-proxy'):
|
elif o in ('--sogou-proxy',):
|
||||||
sogou_proxy = parse_host(a)
|
sogou_proxy = parse_host(a)
|
||||||
elif o in ('--sogou-env'):
|
elif o in ('--sogou-env',):
|
||||||
sogou_env = a
|
sogou_env = a
|
||||||
else:
|
else:
|
||||||
log.e("try 'you-get --help' for more options")
|
log.e("try 'you-get --help' for more options")
|
||||||
|
Loading…
Reference in New Issue
Block a user