mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-03 23:43:21 -04:00
Better Format Sorting (Squashed)
* Added --format-sort (-S height,filesize) * Made fields reversible (-S +height) * Added --format-sort-force, --no-format-sort-force * Added limit (-S height:720) * Added codec preference (-S vcodec,acodec) * Correct handling of preference<-1000 * Rebased to yt-dlc * Automatically determine missing bitrates * aext, vext, protocol, acodec, vcodec can now takes priority as string, not number (-S vext:webm) * Correct handling of None in codec, audio_codec (None means the codec is unknown while 'none' means it doesn't exist) * Correctly parse filesize (-S filesize:200M) * Generalized preference calculation * Rewrote entire code into the class FormatSort * Correctly handle user input errors * Combined fields (-S +ext:webm:webm) * Closest mode (-S filesize~50M) * Aliases (framerate=fps, br=bitrate etc) * Documentation
This commit is contained in:
@@ -8,6 +8,7 @@ __license__ = 'Public Domain'
|
||||
import codecs
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import random
|
||||
import sys
|
||||
|
||||
@@ -41,6 +42,7 @@ from .downloader import (
|
||||
FileDownloader,
|
||||
)
|
||||
from .extractor import gen_extractors, list_extractors
|
||||
from .extractor.common import InfoExtractor
|
||||
from .extractor.adobepass import MSO_INFO
|
||||
from .YoutubeDL import YoutubeDL
|
||||
|
||||
@@ -245,6 +247,9 @@ def _real_main(argv=None):
|
||||
parser.error('Cannot download a video and extract audio into the same'
|
||||
' file! Use "{0}.%(ext)s" instead of "{0}" as the output'
|
||||
' template'.format(outtmpl))
|
||||
for f in opts.format_sort:
|
||||
if re.match(InfoExtractor.FormatSort.regex, f) is None:
|
||||
parser.error('invalid format sort string "%s" specified' % f)
|
||||
|
||||
any_getting = opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat or opts.getduration or opts.dumpjson or opts.dump_single_json
|
||||
any_printing = opts.print_json
|
||||
@@ -347,6 +352,8 @@ def _real_main(argv=None):
|
||||
'simulate': opts.simulate or any_getting,
|
||||
'skip_download': opts.skip_download,
|
||||
'format': opts.format,
|
||||
'format_sort': opts.format_sort,
|
||||
'format_sort_force': opts.format_sort_force,
|
||||
'listformats': opts.listformats,
|
||||
'outtmpl': outtmpl,
|
||||
'autonumber_size': opts.autonumber_size,
|
||||
|
Reference in New Issue
Block a user