diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-13 01:32:19 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-06-13 03:45:53 +0530 |
commit | 8326b00aabc332cad3edec246fe5353bea069cb0 (patch) | |
tree | 286e543dd7b6b447b797ceae8bd8655999f97970 /yt_dlp/extractor/common.py | |
parent | b0249bcaf0f2ac1fafecbf5d44f7403c6f0d5850 (diff) | |
download | hypervideo-pre-8326b00aabc332cad3edec246fe5353bea069cb0.tar.lz hypervideo-pre-8326b00aabc332cad3edec246fe5353bea069cb0.tar.xz hypervideo-pre-8326b00aabc332cad3edec246fe5353bea069cb0.zip |
Allow `images` formats
Necessary for #343.
* They are identified by `vcodec=acodec='none'`
* These formats show as the worst in `-F`
* Any postprocessor that expects audio/video will be skipped
* `b*` and all related selectors will skip such formats
* This commit also does not add any selector for downloading such formats. They have to be explicitly requested by the `format_id`. Implementation of a selector is left for when #389 is resolved
Diffstat (limited to 'yt_dlp/extractor/common.py')
-rw-r--r-- | yt_dlp/extractor/common.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index 3a345b2cd..3603924e4 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -1473,7 +1473,7 @@ class InfoExtractor(object): class FormatSort: regex = r' *((?P<reverse>\+)?(?P<field>[a-zA-Z0-9_]+)((?P<separator>[~:])(?P<limit>.*?))?)? *$' - default = ('hidden', 'hasvid', 'ie_pref', 'lang', 'quality', + default = ('hidden', 'aud_or_vid', 'hasvid', 'ie_pref', 'lang', 'quality', 'res', 'fps', 'codec:vp9.2', 'size', 'br', 'asr', 'proto', 'ext', 'hasaud', 'source', 'format_id') # These must not be aliases ytdl_default = ('hasaud', 'quality', 'tbr', 'filesize', 'vbr', @@ -1494,6 +1494,9 @@ class InfoExtractor(object): 'order': ('m4a', 'aac', 'mp3', 'ogg', 'opus', 'webm', '', 'none'), 'order_free': ('opus', 'ogg', 'webm', 'm4a', 'mp3', 'aac', '', 'none')}, 'hidden': {'visible': False, 'forced': True, 'type': 'extractor', 'max': -1000}, + 'aud_or_vid': {'visible': False, 'forced': True, 'type': 'multiple', 'default': 1, + 'field': ('vcodec', 'acodec'), + 'function': lambda it: int(any(v != 'none' for v in it))}, 'ie_pref': {'priority': True, 'type': 'extractor'}, 'hasvid': {'priority': True, 'field': 'vcodec', 'type': 'boolean', 'not_in_list': ('none',)}, 'hasaud': {'field': 'acodec', 'type': 'boolean', 'not_in_list': ('none',)}, @@ -1701,9 +1704,7 @@ class InfoExtractor(object): def wrapped_function(values): values = tuple(filter(lambda x: x is not None, values)) - return (self._get_field_setting(field, 'function')(*values) if len(values) > 1 - else values[0] if values - else None) + return self._get_field_setting(field, 'function')(values) if values else None value = wrapped_function((get_value(f) for f in actual_fields)) else: @@ -1719,7 +1720,7 @@ class InfoExtractor(object): if not format.get('ext') and 'url' in format: format['ext'] = determine_ext(format['url']) if format.get('vcodec') == 'none': - format['audio_ext'] = format['ext'] + format['audio_ext'] = format['ext'] if format.get('acodec') != 'none' else 'none' format['video_ext'] = 'none' else: format['video_ext'] = format['ext'] |