mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
This commit is contained in:
parent
295df4edb9
commit
c75f0b361a
|
@ -249,10 +249,10 @@ class YoutubeDL(object):
|
||||||
hls_prefer_native: Use the native HLS downloader instead of ffmpeg/avconv.
|
hls_prefer_native: Use the native HLS downloader instead of ffmpeg/avconv.
|
||||||
|
|
||||||
The following parameters are not used by YoutubeDL itself, they are used by
|
The following parameters are not used by YoutubeDL itself, they are used by
|
||||||
the FileDownloader:
|
the downloader (see youtube_dl/downloader/common.py):
|
||||||
nopart, updatetime, buffersize, ratelimit, min_filesize, max_filesize, test,
|
nopart, updatetime, buffersize, ratelimit, min_filesize, max_filesize, test,
|
||||||
noresizebuffer, retries, continuedl, noprogress, consoletitle,
|
noresizebuffer, retries, continuedl, noprogress, consoletitle,
|
||||||
xattr_set_filesize.
|
xattr_set_filesize, external_downloader_args.
|
||||||
|
|
||||||
The following options are used by the post processors:
|
The following options are used by the post processors:
|
||||||
prefer_ffmpeg: If True, use ffmpeg instead of avconv if both are available,
|
prefer_ffmpeg: If True, use ffmpeg instead of avconv if both are available,
|
||||||
|
|
|
@ -9,6 +9,7 @@ import codecs
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
@ -255,6 +256,9 @@ def _real_main(argv=None):
|
||||||
xattr # Confuse flake8
|
xattr # Confuse flake8
|
||||||
except ImportError:
|
except ImportError:
|
||||||
parser.error('setting filesize xattr requested but python-xattr is not available')
|
parser.error('setting filesize xattr requested but python-xattr is not available')
|
||||||
|
external_downloader_args = None
|
||||||
|
if opts.external_downloader_args:
|
||||||
|
external_downloader_args = shlex.split(opts.external_downloader_args)
|
||||||
match_filter = (
|
match_filter = (
|
||||||
None if opts.match_filter is None
|
None if opts.match_filter is None
|
||||||
else match_filter_func(opts.match_filter))
|
else match_filter_func(opts.match_filter))
|
||||||
|
@ -359,6 +363,7 @@ def _real_main(argv=None):
|
||||||
'no_color': opts.no_color,
|
'no_color': opts.no_color,
|
||||||
'ffmpeg_location': opts.ffmpeg_location,
|
'ffmpeg_location': opts.ffmpeg_location,
|
||||||
'hls_prefer_native': opts.hls_prefer_native,
|
'hls_prefer_native': opts.hls_prefer_native,
|
||||||
|
'external_downloader_args': external_downloader_args,
|
||||||
}
|
}
|
||||||
|
|
||||||
with YoutubeDL(ydl_opts) as ydl:
|
with YoutubeDL(ydl_opts) as ydl:
|
||||||
|
|
|
@ -42,6 +42,8 @@ class FileDownloader(object):
|
||||||
max_filesize: Skip files larger than this size
|
max_filesize: Skip files larger than this size
|
||||||
xattr_set_filesize: Set ytdl.filesize user xattribute with expected size.
|
xattr_set_filesize: Set ytdl.filesize user xattribute with expected size.
|
||||||
(experimenatal)
|
(experimenatal)
|
||||||
|
external_downloader_args: A list of additional command-line arguments for the
|
||||||
|
external downloader.
|
||||||
|
|
||||||
Subclasses of this one must re-define the real_download method.
|
Subclasses of this one must re-define the real_download method.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -51,6 +51,13 @@ class ExternalFD(FileDownloader):
|
||||||
return []
|
return []
|
||||||
return [command_option, source_address]
|
return [command_option, source_address]
|
||||||
|
|
||||||
|
def _configuration_args(self, default=[]):
|
||||||
|
ex_args = self.params.get('external_downloader_args')
|
||||||
|
if ex_args is None:
|
||||||
|
return default
|
||||||
|
assert isinstance(ex_args, list)
|
||||||
|
return ex_args
|
||||||
|
|
||||||
def _call_downloader(self, tmpfilename, info_dict):
|
def _call_downloader(self, tmpfilename, info_dict):
|
||||||
""" Either overwrite this or implement _make_cmd """
|
""" Either overwrite this or implement _make_cmd """
|
||||||
cmd = self._make_cmd(tmpfilename, info_dict)
|
cmd = self._make_cmd(tmpfilename, info_dict)
|
||||||
|
@ -79,6 +86,7 @@ class CurlFD(ExternalFD):
|
||||||
for key, val in info_dict['http_headers'].items():
|
for key, val in info_dict['http_headers'].items():
|
||||||
cmd += ['--header', '%s: %s' % (key, val)]
|
cmd += ['--header', '%s: %s' % (key, val)]
|
||||||
cmd += self._source_address('--interface')
|
cmd += self._source_address('--interface')
|
||||||
|
cmd += self._configuration_args()
|
||||||
cmd += ['--', info_dict['url']]
|
cmd += ['--', info_dict['url']]
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
@ -89,15 +97,16 @@ class WgetFD(ExternalFD):
|
||||||
for key, val in info_dict['http_headers'].items():
|
for key, val in info_dict['http_headers'].items():
|
||||||
cmd += ['--header', '%s: %s' % (key, val)]
|
cmd += ['--header', '%s: %s' % (key, val)]
|
||||||
cmd += self._source_address('--bind-address')
|
cmd += self._source_address('--bind-address')
|
||||||
|
cmd += self._configuration_args()
|
||||||
cmd += ['--', info_dict['url']]
|
cmd += ['--', info_dict['url']]
|
||||||
return cmd
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
class Aria2cFD(ExternalFD):
|
class Aria2cFD(ExternalFD):
|
||||||
def _make_cmd(self, tmpfilename, info_dict):
|
def _make_cmd(self, tmpfilename, info_dict):
|
||||||
cmd = [
|
cmd = [self.exe, '-c']
|
||||||
self.exe, '-c',
|
cmd += self._configuration_args([
|
||||||
'--min-split-size', '1M', '--max-connection-per-server', '4']
|
'--min-split-size', '1M', '--max-connection-per-server', '4'])
|
||||||
dn = os.path.dirname(tmpfilename)
|
dn = os.path.dirname(tmpfilename)
|
||||||
if dn:
|
if dn:
|
||||||
cmd += ['--dir', dn]
|
cmd += ['--dir', dn]
|
||||||
|
|
|
@ -435,8 +435,12 @@ def parseOpts(overrideArguments=None):
|
||||||
downloader.add_option(
|
downloader.add_option(
|
||||||
'--external-downloader',
|
'--external-downloader',
|
||||||
dest='external_downloader', metavar='COMMAND',
|
dest='external_downloader', metavar='COMMAND',
|
||||||
help='(experimental) Use the specified external downloader. '
|
help='Use the specified external downloader. '
|
||||||
'Currently supports %s' % ','.join(list_external_downloaders()))
|
'Currently supports %s' % ','.join(list_external_downloaders()))
|
||||||
|
downloader.add_option(
|
||||||
|
'--external-downloader-args',
|
||||||
|
dest='external_downloader_args', metavar='ARGS',
|
||||||
|
help='Give these arguments to the external downloader.')
|
||||||
|
|
||||||
workarounds = optparse.OptionGroup(parser, 'Workarounds')
|
workarounds = optparse.OptionGroup(parser, 'Workarounds')
|
||||||
workarounds.add_option(
|
workarounds.add_option(
|
||||||
|
|
Loading…
Reference in a new issue