From da9be05edfae2dae0c8019504a557568794a2aad Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 18 Feb 2021 19:47:46 +0530 Subject: [PATCH] [documentation] Better document `--prefer-free-formats` Also added `--no-prefer-free-formats` --- README.md | 8 ++++++-- youtube_dlc/extractor/common.py | 5 ++--- youtube_dlc/options.py | 8 +++++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cc454aac4..520a85d7e 100644 --- a/README.md +++ b/README.md @@ -520,8 +520,12 @@ Then simply type this --no-audio-multistreams Only one audio stream is downloaded for each output file (default) --all-formats Download all available video formats - --prefer-free-formats Prefer free video formats over non-free - formats of same quality + --prefer-free-formats Prefer video formats with free containers + over non-free ones of same quality. Use + with "-S ext" to strictly prefer free + containers irrespective of quality + --no-prefer-free-formats Don't give any special preference to free + containers (default) -F, --list-formats List all available formats of requested videos --list-formats-as-table Present the output of -F in tabular form diff --git a/youtube_dlc/extractor/common.py b/youtube_dlc/extractor/common.py index 072ae5b81..49df880d0 100644 --- a/youtube_dlc/extractor/common.py +++ b/youtube_dlc/extractor/common.py @@ -1469,13 +1469,12 @@ class InfoExtractor(object): elif conversion == 'bytes': return FileDownloader.parse_bytes(value) elif conversion == 'order': - order_free = self._get_field_setting(field, 'order_free') - order_list = order_free if order_free and self._use_free_order else self._get_field_setting(field, 'order') + order_list = (self._use_free_order and self._get_field_setting(field, 'order_free')) or self._get_field_setting(field, 'order') use_regex = self._get_field_setting(field, 'regex') list_length = len(order_list) empty_pos = order_list.index('') if '' in order_list else list_length + 1 if use_regex and value is not None: - for (i, regex) in enumerate(order_list): + for i, regex in enumerate(order_list): if regex and re.match(regex, value): return list_length - i return list_length - empty_pos # not in list diff --git a/youtube_dlc/options.py b/youtube_dlc/options.py index bb37554ec..93f972133 100644 --- a/youtube_dlc/options.py +++ b/youtube_dlc/options.py @@ -483,7 +483,13 @@ def parseOpts(overrideArguments=None): video_format.add_option( '--prefer-free-formats', action='store_true', dest='prefer_free_formats', default=False, - help='Prefer free video formats over non-free formats of same quality') + help=( + 'Prefer video formats with free containers over non-free ones of same quality. ' + 'Use with "-S ext" to strictly prefer free containers irrespective of quality')) + video_format.add_option( + '--no-prefer-free-formats', + action='store_true', dest='prefer_free_formats', default=False, + help="Don't give any special preference to free containers (default)") video_format.add_option( '-F', '--list-formats', action='store_true', dest='listformats',