Change defaults

* Enabled --ignore by default
* Disabled --video-multistreams and --audio-multistreams by default
* Changed default format selection to 'bv*+ba/b' when --audio-multistreams is disabled
* Changed default format sort order to 'res,fps,codec,size,br,asr,proto,ext,has_audio,source,format_id'
* Changed default output template to '%(title)s [%(id)s].%(ext)s'
* Enabled `--list-formats-as-table` by default
This commit is contained in:
pukkandan 2021-01-04 22:10:47 +05:30
parent 50865ca803
commit 91ebc64068
5 changed files with 43 additions and 45 deletions

View File

@ -169,7 +169,7 @@ # OPTIONS
-i, --ignore-errors Continue on download errors, for example to -i, --ignore-errors Continue on download errors, for example to
skip unavailable videos in a playlist skip unavailable videos in a playlist
(Same as --no-abort-on-error) (default) (Same as --no-abort-on-error)
--abort-on-error Abort downloading of further videos if an --abort-on-error Abort downloading of further videos if an
error occurs (Same as --no-ignore-errors) error occurs (Same as --no-ignore-errors)
--dump-user-agent Display the current browser identification --dump-user-agent Display the current browser identification
@ -498,20 +498,21 @@ ## Video Format Options:
specified sort order, see "Sorting Formats" specified sort order, see "Sorting Formats"
for more details (default) for more details (default)
--video-multistreams Allow multiple video streams to be merged into --video-multistreams Allow multiple video streams to be merged into
a single file (default) a single file
--no-video-multistreams Only one video stream is downloaded for each --no-video-multistreams Only one video stream is downloaded for each
output file output file (default)
--audio-multistreams Allow multiple audio streams to be merged into --audio-multistreams Allow multiple audio streams to be merged into
a single file (default) a single file
--no-audio-multistreams Only one audio stream is downloaded for each --no-audio-multistreams Only one audio stream is downloaded for each
output file output file (default)
--all-formats Download all available video formats --all-formats Download all available video formats
--prefer-free-formats Prefer free video formats unless a specific --prefer-free-formats Prefer free video formats unless a specific
one is requested one is requested
-F, --list-formats List all available formats of requested -F, --list-formats List all available formats of requested
videos videos
--list-formats-as-table Present the output of -F in a more tabular form --list-formats-as-table Present the output of -F in a more tabular
--list-formats-old Present the output of -F in older form (default) form (default)
--list-formats-old Present the output of -F in older form
(Same as --no-list-formats-as-table) (Same as --no-list-formats-as-table)
--youtube-skip-dash-manifest Do not download the DASH manifests and --youtube-skip-dash-manifest Do not download the DASH manifests and
related data on YouTube videos related data on YouTube videos
@ -807,7 +808,7 @@ # OUTPUT TEMPLATE
To use percent literals in an output template use `%%`. To output to stdout use `-o -`. To use percent literals in an output template use `%%`. To output to stdout use `-o -`.
The current default template is `%(title)s-%(id)s.%(ext)s`. The current default template is `%(title)s [%(id)s].%(ext)s`.
In some cases, you don't want special characters such as 中, spaces, or &, such as when transferring the downloaded filename to a Windows system or the filename through an 8bit-unsafe channel. In these cases, add the `--restrict-filenames` flag to get a shorter title: In some cases, you don't want special characters such as 中, spaces, or &, such as when transferring the downloaded filename to a Windows system or the filename through an 8bit-unsafe channel. In these cases, add the `--restrict-filenames` flag to get a shorter title:
@ -845,7 +846,7 @@ # Stream the video being downloaded to stdout
# FORMAT SELECTION # FORMAT SELECTION
By default, youtube-dlc tries to download the best available quality if you **don't** pass any options. By default, youtube-dlc tries to download the best available quality if you **don't** pass any options.
This is generally equivalent to using `-f bestvideo+bestaudio/best`. However, if ffmpeg and avconv are unavailable, or if you use youtube-dlc to stream to `stdout` (`-o -`), the default becomes `-f best/bestvideo+bestaudio`. This is generally equivalent to using `-f bestvideo*+bestaudio/best`. However, if multiple audiostreams is enabled (`--audio-multistreams`), the default format changes to `-f bestvideo+bestaudio/best`. Similarly, if ffmpeg and avconv are unavailable, or if you use youtube-dlc to stream to `stdout` (`-o -`), the default becomes `-f best/bestvideo+bestaudio`.
The general syntax for format selection is `--f FORMAT` (or `--format FORMAT`) where `FORMAT` is a *selector expression*, i.e. an expression that describes format or formats you would like to download. The general syntax for format selection is `--f FORMAT` (or `--format FORMAT`) where `FORMAT` is a *selector expression*, i.e. an expression that describes format or formats you would like to download.
@ -948,7 +949,7 @@ ## Sorting Formats
Note that any other **numerical** field made available by the extractor can also be used. All fields, unless specified otherwise, are sorted in decending order. To reverse this, prefix the field with a `+`. Eg: `+res` prefers format with the smallest resolution. Additionally, you can suffix a prefered value for the fields, seperated by a `:`. Eg: `res:720` prefers larger videos, but no larger than 720p and the smallest video if there are no videos less than 720p. For `codec` and `ext`, you can provide two prefered values, the first for video and the second for audio. Eg: `+codec:avc:m4a` (equivalent to `+vcodec:avc,+acodec:m4a`) sets the video codec preference to `h264` > `h265` > `vp9` > `av01` > `vp8` > `h263` > `theora` and audio codec preference to `mp4a` > `aac` > `vorbis` > `opus` > `mp3` > `ac3` > `dts`. You can also make the sorting prefer the nearest values to the provided by using `~` as the delimiter. Eg: `filesize~1G` prefers the format with filesize closest to 1 GiB. Note that any other **numerical** field made available by the extractor can also be used. All fields, unless specified otherwise, are sorted in decending order. To reverse this, prefix the field with a `+`. Eg: `+res` prefers format with the smallest resolution. Additionally, you can suffix a prefered value for the fields, seperated by a `:`. Eg: `res:720` prefers larger videos, but no larger than 720p and the smallest video if there are no videos less than 720p. For `codec` and `ext`, you can provide two prefered values, the first for video and the second for audio. Eg: `+codec:avc:m4a` (equivalent to `+vcodec:avc,+acodec:m4a`) sets the video codec preference to `h264` > `h265` > `vp9` > `av01` > `vp8` > `h263` > `theora` and audio codec preference to `mp4a` > `aac` > `vorbis` > `opus` > `mp3` > `ac3` > `dts`. You can also make the sorting prefer the nearest values to the provided by using `~` as the delimiter. Eg: `filesize~1G` prefers the format with filesize closest to 1 GiB.
The fields `has_video`, `extractor`, `lang`, `quality` are always given highest priority in sorting, irrespective of the user-defined order. This behaviour can be changed by using `--force-format-sort`. Apart from these, the default order used by youtube-dlc is: `tbr,filesize,vbr,height,width,protocol,vext,abr,aext,fps,filesize_approx,source_preference,format_id`. Note that the extractors may override this default order, but not the user-provided order. The fields `has_video`, `extractor`, `lang`, `quality` are always given highest priority in sorting, irrespective of the user-defined order. This behaviour can be changed by using `--force-format-sort`. Apart from these, the default order used by youtube-dlc is: `res,fps,codec,size,br,asr,proto,ext,has_audio,source,format_id`. Note that the extractors may override this default order, but not the user-provided order.
If your format selector is `worst`, the last item is selected after sorting. This means it will select the format that is worst in all repects. Most of the time, what you actually want is the video with the smallest filesize instead. So it is generally better to use `-f best -S +size,+br,+res,+fps`. If your format selector is `worst`, the last item is selected after sorting. This means it will select the format that is worst in all repects. Most of the time, what you actually want is the video with the smallest filesize instead. So it is generally better to use `-f best -S +size,+br,+res,+fps`.

View File

@ -178,7 +178,7 @@ class YoutubeDL(object):
outtmpl: Template for output names. outtmpl: Template for output names.
restrictfilenames: Do not allow "&" and spaces in file names. restrictfilenames: Do not allow "&" and spaces in file names.
trim_file_name: Limit length of filename (extension excluded). trim_file_name: Limit length of filename (extension excluded).
ignoreerrors: Do not stop on download errors. ignoreerrors: Do not stop on download errors. (Default False when running youtube-dlc, but True when directly accessing YoutubeDL class)
force_generic_extractor: Force downloader to use the generic extractor force_generic_extractor: Force downloader to use the generic extractor
nooverwrites: Prevent overwriting files. nooverwrites: Prevent overwriting files.
playliststart: Playlist item to start at. playliststart: Playlist item to start at.
@ -1185,23 +1185,20 @@ def can_merge():
merger = FFmpegMergerPP(self) merger = FFmpegMergerPP(self)
return merger.available and merger.can_merge() return merger.available and merger.can_merge()
def prefer_best(): prefer_best = (
if self.params.get('simulate', False): not self.params.get('simulate', False)
return False and download
if not download: and (
return False not can_merge()
if self.params.get('outtmpl', DEFAULT_OUTTMPL) == '-': or info_dict.get('is_live')
return True or self.params.get('outtmpl', DEFAULT_OUTTMPL) == '-'))
if info_dict.get('is_live'):
return True
if not can_merge():
return True
return False
req_format_list = ['bestvideo+bestaudio', 'best'] return (
if prefer_best(): 'best/bestvideo+bestaudio'
req_format_list.reverse() if prefer_best
return '/'.join(req_format_list) else 'bestvideo*+bestaudio/best'
if self.params.get('allow_multiple_audio_streams', False)
else 'bestvideo+bestaudio/best')
def build_format_selector(self, format_spec): def build_format_selector(self, format_spec):
def syntax_error(note, start): def syntax_error(note, start):
@ -1216,8 +1213,8 @@ def syntax_error(note, start):
GROUP = 'GROUP' GROUP = 'GROUP'
FormatSelector = collections.namedtuple('FormatSelector', ['type', 'selector', 'filters']) FormatSelector = collections.namedtuple('FormatSelector', ['type', 'selector', 'filters'])
allow_multiple_streams = {'audio': self.params.get('allow_multiple_audio_streams', True), allow_multiple_streams = {'audio': self.params.get('allow_multiple_audio_streams', False),
'video': self.params.get('allow_multiple_video_streams', True)} 'video': self.params.get('allow_multiple_video_streams', False)}
def _parse_filter(tokens): def _parse_filter(tokens):
filter_parts = [] filter_parts = []

View File

@ -1367,8 +1367,8 @@ class FormatSort:
regex = r' *((?P<reverse>\+)?(?P<field>[a-zA-Z0-9_]+)((?P<seperator>[~:])(?P<limit>.*?))?)? *$' regex = r' *((?P<reverse>\+)?(?P<field>[a-zA-Z0-9_]+)((?P<seperator>[~:])(?P<limit>.*?))?)? *$'
default = ('hidden', 'has_video', 'extractor', 'lang', 'quality', default = ('hidden', 'has_video', 'extractor', 'lang', 'quality',
'tbr', 'filesize', 'vbr', 'height', 'width', 'protocol', 'vext', 'res', 'fps', 'codec', 'size', 'br', 'asr',
'abr', 'aext', 'fps', 'filesize_approx', 'source_preference', 'format_id') 'proto', 'ext', 'has_audio', 'source', 'format_id')
settings = { settings = {
'vcodec': {'type': 'ordered', 'regex': True, 'vcodec': {'type': 'ordered', 'regex': True,
@ -1378,7 +1378,7 @@ class FormatSort:
'protocol': {'type': 'ordered', 'regex': True, 'protocol': {'type': 'ordered', 'regex': True,
'order': ['(ht|f)tps', '(ht|f)tp$', 'm3u8.+', 'm3u8', '.*dash', '', 'mms|rtsp', 'none', 'f4']}, 'order': ['(ht|f)tps', '(ht|f)tp$', 'm3u8.+', 'm3u8', '.*dash', '', 'mms|rtsp', 'none', 'f4']},
'vext': {'type': 'ordered', 'field': 'video_ext', 'vext': {'type': 'ordered', 'field': 'video_ext',
'order': ('mp4', 'flv', 'webm', '', 'none'), # Why is flv prefered over webm??? 'order': ('mp4', 'webm', 'flv', '', 'none'),
'order_free': ('webm', 'mp4', 'flv', '', 'none')}, 'order_free': ('webm', 'mp4', 'flv', '', 'none')},
'aext': {'type': 'ordered', 'field': 'audio_ext', 'aext': {'type': 'ordered', 'field': 'audio_ext',
'order': ('m4a', 'aac', 'mp3', 'ogg', 'opus', 'webm', '', 'none'), 'order': ('m4a', 'aac', 'mp3', 'ogg', 'opus', 'webm', '', 'none'),
@ -1386,7 +1386,7 @@ class FormatSort:
'hidden': {'visible': False, 'forced': True, 'type': 'extractor', 'max': -1000}, 'hidden': {'visible': False, 'forced': True, 'type': 'extractor', 'max': -1000},
'extractor_preference': {'priority': True, 'type': 'extractor'}, 'extractor_preference': {'priority': True, 'type': 'extractor'},
'has_video': {'priority': True, 'field': 'vcodec', 'type': 'boolean', 'not_in_list': ('none',)}, 'has_video': {'priority': True, 'field': 'vcodec', 'type': 'boolean', 'not_in_list': ('none',)},
'has_audio': {'priority': False, 'field': 'acodec', 'type': 'boolean', 'not_in_list': ('none',)}, 'has_audio': {'field': 'acodec', 'type': 'boolean', 'not_in_list': ('none',)},
'language_preference': {'priority': True, 'convert': 'ignore'}, 'language_preference': {'priority': True, 'convert': 'ignore'},
'quality': {'priority': True, 'convert': 'float_none'}, 'quality': {'priority': True, 'convert': 'float_none'},
'filesize': {'convert': 'bytes'}, 'filesize': {'convert': 'bytes'},

View File

@ -143,12 +143,12 @@ def _comma_separated_values_options_callback(option, opt_str, value, parser):
help='Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)') help='Update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)')
general.add_option( general.add_option(
'-i', '--ignore-errors', '--no-abort-on-error', '-i', '--ignore-errors', '--no-abort-on-error',
action='store_true', dest='ignoreerrors', default=False, action='store_true', dest='ignoreerrors', default=True,
help='Continue on download errors, for example to skip unavailable videos in a playlist') help='Continue on download errors, for example to skip unavailable videos in a playlist (default)')
general.add_option( general.add_option(
'--abort-on-error', '--no-ignore-errors', '--abort-on-error', '--no-ignore-errors',
action='store_false', dest='ignoreerrors', action='store_false', dest='ignoreerrors',
help='Abort downloading of further videos if an error occurs (default)') help='Abort downloading of further videos if an error occurs')
general.add_option( general.add_option(
'--dump-user-agent', '--dump-user-agent',
action='store_true', dest='dump_user_agent', default=False, action='store_true', dest='dump_user_agent', default=False,
@ -438,20 +438,20 @@ def _comma_separated_values_options_callback(option, opt_str, value, parser):
'see "Sorting Formats" for more details')) 'see "Sorting Formats" for more details'))
video_format.add_option( video_format.add_option(
'--video-multistreams', '--video-multistreams',
action='store_true', dest='allow_multiple_video_streams', default=True, action='store_true', dest='allow_multiple_video_streams', default=False,
help='Allow multiple video streams to be merged into a single file (default)') help='Allow multiple video streams to be merged into a single file')
video_format.add_option( video_format.add_option(
'--no-video-multistreams', '--no-video-multistreams',
action='store_false', dest='allow_multiple_video_streams', action='store_false', dest='allow_multiple_video_streams',
help='Only one video stream is downloaded for each output file') help='Only one video stream is downloaded for each output file (default)')
video_format.add_option( video_format.add_option(
'--audio-multistreams', '--audio-multistreams',
action='store_true', dest='allow_multiple_audio_streams', default=True, action='store_true', dest='allow_multiple_audio_streams', default=False,
help='Allow multiple audio streams to be merged into a single file (default)') help='Allow multiple audio streams to be merged into a single file')
video_format.add_option( video_format.add_option(
'--no-audio-multistreams', '--no-audio-multistreams',
action='store_false', dest='allow_multiple_audio_streams', action='store_false', dest='allow_multiple_audio_streams',
help='Only one audio stream is downloaded for each output file') help='Only one audio stream is downloaded for each output file (default)')
video_format.add_option( video_format.add_option(
'--all-formats', '--all-formats',
action='store_const', dest='format', const='all', action='store_const', dest='format', const='all',
@ -466,8 +466,8 @@ def _comma_separated_values_options_callback(option, opt_str, value, parser):
help='List all available formats of requested videos') help='List all available formats of requested videos')
video_format.add_option( video_format.add_option(
'--list-formats-as-table', '--list-formats-as-table',
action='store_true', dest='listformats_table', default=False, action='store_true', dest='listformats_table', default=True,
help='Present the output of -F in a more tabular form') help='Present the output of -F in a more tabular form (default)')
video_format.add_option( video_format.add_option(
'--list-formats-old', '--no-list-formats-as-table', '--list-formats-old', '--no-list-formats-as-table',
action='store_false', dest='listformats_table', action='store_false', dest='listformats_table',

View File

@ -4128,7 +4128,7 @@ def q(qid):
return q return q
DEFAULT_OUTTMPL = '%(title)s-%(id)s.%(ext)s' DEFAULT_OUTTMPL = '%(title)s [%(id)s].%(ext)s'
def limit_length(s, length): def limit_length(s, length):