mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-05 01:25:54 +08:00
Add --skip-protocols to exclude specific protocols from format extraction
This commit is contained in:
parent
3f7e8750d4
commit
a9308ca601
@ -373,6 +373,7 @@ def _real_main(argv=None):
|
||||
'external_downloader_args': external_downloader_args,
|
||||
'postprocessor_args': postprocessor_args,
|
||||
'cn_verification_proxy': opts.cn_verification_proxy,
|
||||
'skip_protocols': opts.skip_protocols,
|
||||
}
|
||||
|
||||
with YoutubeDL(ydl_opts) as ydl:
|
||||
|
@ -939,6 +939,8 @@ class InfoExtractor(object):
|
||||
def _extract_f4m_formats(self, manifest_url, video_id, preference=None, f4m_id=None,
|
||||
transform_source=lambda s: fix_xml_ampersands(s).strip(),
|
||||
fatal=True):
|
||||
if 'f4m' in self._downloader.params.get('skip_protocols'):
|
||||
return []
|
||||
manifest = self._download_xml(
|
||||
manifest_url, video_id, 'Downloading f4m manifest',
|
||||
'Unable to download f4m manifest',
|
||||
@ -995,6 +997,8 @@ class InfoExtractor(object):
|
||||
entry_protocol='m3u8', preference=None,
|
||||
m3u8_id=None, note=None, errnote=None,
|
||||
fatal=True):
|
||||
if 'm3u8' in self._downloader.params.get('skip_protocols'):
|
||||
return []
|
||||
|
||||
formats = [{
|
||||
'format_id': '-'.join(filter(None, [m3u8_id, 'meta'])),
|
||||
@ -1105,6 +1109,8 @@ class InfoExtractor(object):
|
||||
return '/'.join(out)
|
||||
|
||||
def _extract_smil_formats(self, smil_url, video_id, fatal=True, f4m_params=None):
|
||||
if 'smil' in self._downloader.params.get('skip_protocols'):
|
||||
return []
|
||||
smil = self._download_smil(smil_url, video_id, fatal=fatal)
|
||||
|
||||
if smil is False:
|
||||
@ -1338,6 +1344,8 @@ class InfoExtractor(object):
|
||||
fatal=fatal)
|
||||
|
||||
def _extract_dash_manifest_formats(self, dash_manifest_url, video_id, fatal=True, namespace=None, formats_dict={}):
|
||||
if 'dash' in self._downloader.params.get('skip_protocols'):
|
||||
return []
|
||||
dash_doc = self._download_dash_manifest(dash_manifest_url, video_id, fatal)
|
||||
if dash_doc is False:
|
||||
return []
|
||||
|
@ -354,6 +354,11 @@ def parseOpts(overrideArguments=None):
|
||||
'If a merge is required (e.g. bestvideo+bestaudio), '
|
||||
'output to given container format. One of mkv, mp4, ogg, webm, flv. '
|
||||
'Ignored if no merge is required'))
|
||||
video_format.add_option(
|
||||
'--skip-protocols',
|
||||
action='callback', dest='skip_protocols', type='str',
|
||||
default=[], callback=_comma_separated_values_options_callback,
|
||||
help='Protocols to exclude from the format extraction separated by commas (Possible values: m3u8, f4m, dash and smil)')
|
||||
|
||||
subtitles = optparse.OptionGroup(parser, 'Subtitle Options')
|
||||
subtitles.add_option(
|
||||
|
Loading…
Reference in New Issue
Block a user