mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-05 06:52:52 +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,
|
'external_downloader_args': external_downloader_args,
|
||||||
'postprocessor_args': postprocessor_args,
|
'postprocessor_args': postprocessor_args,
|
||||||
'cn_verification_proxy': opts.cn_verification_proxy,
|
'cn_verification_proxy': opts.cn_verification_proxy,
|
||||||
|
'skip_protocols': opts.skip_protocols,
|
||||||
}
|
}
|
||||||
|
|
||||||
with YoutubeDL(ydl_opts) as ydl:
|
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,
|
def _extract_f4m_formats(self, manifest_url, video_id, preference=None, f4m_id=None,
|
||||||
transform_source=lambda s: fix_xml_ampersands(s).strip(),
|
transform_source=lambda s: fix_xml_ampersands(s).strip(),
|
||||||
fatal=True):
|
fatal=True):
|
||||||
|
if 'f4m' in self._downloader.params.get('skip_protocols'):
|
||||||
|
return []
|
||||||
manifest = self._download_xml(
|
manifest = self._download_xml(
|
||||||
manifest_url, video_id, 'Downloading f4m manifest',
|
manifest_url, video_id, 'Downloading f4m manifest',
|
||||||
'Unable to download f4m manifest',
|
'Unable to download f4m manifest',
|
||||||
@ -995,6 +997,8 @@ class InfoExtractor(object):
|
|||||||
entry_protocol='m3u8', preference=None,
|
entry_protocol='m3u8', preference=None,
|
||||||
m3u8_id=None, note=None, errnote=None,
|
m3u8_id=None, note=None, errnote=None,
|
||||||
fatal=True):
|
fatal=True):
|
||||||
|
if 'm3u8' in self._downloader.params.get('skip_protocols'):
|
||||||
|
return []
|
||||||
|
|
||||||
formats = [{
|
formats = [{
|
||||||
'format_id': '-'.join(filter(None, [m3u8_id, 'meta'])),
|
'format_id': '-'.join(filter(None, [m3u8_id, 'meta'])),
|
||||||
@ -1105,6 +1109,8 @@ class InfoExtractor(object):
|
|||||||
return '/'.join(out)
|
return '/'.join(out)
|
||||||
|
|
||||||
def _extract_smil_formats(self, smil_url, video_id, fatal=True, f4m_params=None):
|
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)
|
smil = self._download_smil(smil_url, video_id, fatal=fatal)
|
||||||
|
|
||||||
if smil is False:
|
if smil is False:
|
||||||
@ -1338,6 +1344,8 @@ class InfoExtractor(object):
|
|||||||
fatal=fatal)
|
fatal=fatal)
|
||||||
|
|
||||||
def _extract_dash_manifest_formats(self, dash_manifest_url, video_id, fatal=True, namespace=None, formats_dict={}):
|
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)
|
dash_doc = self._download_dash_manifest(dash_manifest_url, video_id, fatal)
|
||||||
if dash_doc is False:
|
if dash_doc is False:
|
||||||
return []
|
return []
|
||||||
|
@ -354,6 +354,11 @@ def parseOpts(overrideArguments=None):
|
|||||||
'If a merge is required (e.g. bestvideo+bestaudio), '
|
'If a merge is required (e.g. bestvideo+bestaudio), '
|
||||||
'output to given container format. One of mkv, mp4, ogg, webm, flv. '
|
'output to given container format. One of mkv, mp4, ogg, webm, flv. '
|
||||||
'Ignored if no merge is required'))
|
'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 = optparse.OptionGroup(parser, 'Subtitle Options')
|
||||||
subtitles.add_option(
|
subtitles.add_option(
|
||||||
|
Loading…
Reference in New Issue
Block a user