From 663e53a95f5435afd95a03bb8b16c6d1fac283a5 Mon Sep 17 00:00:00 2001 From: zhouyuan1 Date: Thu, 20 May 2021 13:03:03 +0800 Subject: [PATCH] add param m3u8 , allow download video via m3u8 url --- src/you_get/common.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index 67ef581b..6e619c11 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -1321,7 +1321,13 @@ def download_main(download, download_playlist, urls, playlist, **kwargs): if re.match(r'https?://', url) is None: url = 'http://' + url - if playlist: + if m3u8: + if output_filename: + title = output_filename + else: + title = "m3u8file" + download_url_ffmpeg(url=url, title=title,ext = 'mp4',output_dir = '.') + elif playlist: download_playlist(url, **kwargs) else: download(url, **kwargs) @@ -1425,7 +1431,6 @@ def set_socks_proxy(proxy): proxy_info = proxy.split("@") socks_proxy_addrs = proxy_info[1].split(':') socks_proxy_auth = proxy_info[0].split(":") - print(socks_proxy_auth[0]+" "+socks_proxy_auth[1]+" "+socks_proxy_addrs[0]+" "+socks_proxy_addrs[1]) socks.set_default_proxy( socks.SOCKS5, socks_proxy_addrs[0], @@ -1436,7 +1441,6 @@ def set_socks_proxy(proxy): ) else: socks_proxy_addrs = proxy.split(':') - print(socks_proxy_addrs[0]+" "+socks_proxy_addrs[1]) socks.set_default_proxy( socks.SOCKS5, socks_proxy_addrs[0], @@ -1601,6 +1605,10 @@ def script_main(download, download_playlist, **kwargs): download_grp.add_argument('--stream', help=argparse.SUPPRESS) download_grp.add_argument('--itag', help=argparse.SUPPRESS) + download_grp.add_argument('-m', '--m3u8', action='store_true', default=False, + help = 'download vide using an m3u8 url') + + parser.add_argument('URL', nargs='*', help=argparse.SUPPRESS) args = parser.parse_args() @@ -1626,6 +1634,7 @@ def script_main(download, download_playlist, **kwargs): global output_filename global auto_rename global insecure + global m3u8 output_filename = args.output_filename extractor_proxy = args.extractor_proxy @@ -1647,6 +1656,9 @@ def script_main(download, download_playlist, **kwargs): if args.cookies: load_cookies(args.cookies) + if args.m3u8: + m3u8 = True + caption = True stream_id = args.format or args.stream or args.itag if args.no_caption: