[formatsort] Remove forced priority of quality
When making `FormatSort`, I misinterpreted the purpose `quality`
This commit is contained in:
parent
da9be05edf
commit
dca3ff4a5e
5 changed files with 14 additions and 12 deletions
|
@ -986,7 +986,7 @@ You can change the criteria for being considered the `best` by using `-S` (`--fo
|
|||
- `hasaud`: Gives priority to formats that has a audio stream
|
||||
- `ie_pref`: The format preference as given by the extractor
|
||||
- `lang`: Language preference as given by the extractor
|
||||
- `quality`: The quality of the format. This is a metadata field available in some websites
|
||||
- `quality`: The quality of the format as given by the extractor
|
||||
- `source`: Preference of the source as given by the extractor
|
||||
- `proto`: Protocol used for download (`https`/`ftps` > `http`/`ftp` > `m3u8-native` > `m3u8` > `http-dash-segments` > other > `mms`/`rtsp` > unknown > `f4f`/`f4m`)
|
||||
- `vcodec`: Video Codec (`av01` > `vp9.2` > `vp9` > `h265` > `h264` > `vp8` > `h263` > `theora` > other > unknown)
|
||||
|
@ -1010,7 +1010,7 @@ You can change the criteria for being considered the `best` by using `-S` (`--fo
|
|||
|
||||
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` > `vp9.2` > `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 `hasvid`, `ie_pref`, `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 is: `res,fps,codec:vp9,size,br,asr,proto,ext,hasaud,source,id`. Note that the extractors may override this default order, but they cannot override the user-provided order.
|
||||
The fields `hasvid`, `ie_pref`, `lang` 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 is: `quality,res,fps,codec:vp9.2,size,br,asr,proto,ext,hasaud,source,id`. Note that the extractors may override this default order, but they cannot override 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`.
|
||||
|
||||
|
|
|
@ -2716,8 +2716,6 @@ class YoutubeDL(object):
|
|||
if f.get('preference') is None or f['preference'] >= -1000]
|
||||
header_line = ['format code', 'extension', 'resolution', 'note']
|
||||
|
||||
# if len(formats) > 1:
|
||||
# table[-1][-1] += (' ' if table[-1][-1] else '') + '(best)'
|
||||
self.to_screen(
|
||||
'[info] Available formats for %s:\n%s' % (info_dict['id'], render_table(
|
||||
header_line,
|
||||
|
|
|
@ -168,7 +168,9 @@ class ArteTVIE(ArteTVBaseIE):
|
|||
|
||||
formats.append(format)
|
||||
|
||||
self._sort_formats(formats)
|
||||
# For this extractor, quality only represents the relative quality
|
||||
# with respect to other formats with the same resolution
|
||||
self._sort_formats(formats, ('res', 'quality'))
|
||||
|
||||
return {
|
||||
'id': player_info.get('VID') or video_id,
|
||||
|
|
|
@ -1388,7 +1388,7 @@ class InfoExtractor(object):
|
|||
'hasvid': {'priority': True, 'field': 'vcodec', 'type': 'boolean', 'not_in_list': ('none',)},
|
||||
'hasaud': {'field': 'acodec', 'type': 'boolean', 'not_in_list': ('none',)},
|
||||
'lang': {'priority': True, 'convert': 'ignore', 'field': 'language_preference'},
|
||||
'quality': {'priority': True, 'convert': 'float_none'},
|
||||
'quality': {'convert': 'float_none'},
|
||||
'filesize': {'convert': 'bytes'},
|
||||
'fs_approx': {'convert': 'bytes', 'field': 'filesize_approx'},
|
||||
'id': {'convert': 'string', 'field': 'format_id'},
|
||||
|
|
|
@ -32,7 +32,7 @@ from ..utils import (
|
|||
mimetype2ext,
|
||||
parse_codecs,
|
||||
parse_duration,
|
||||
# qualities, # TODO: Enable this after fixing formatSort
|
||||
qualities,
|
||||
remove_start,
|
||||
smuggle_url,
|
||||
str_or_none,
|
||||
|
@ -1528,8 +1528,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||
itags = []
|
||||
itag_qualities = {}
|
||||
player_url = None
|
||||
# TODO: Enable this after fixing formatSort
|
||||
# q = qualities(['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'])
|
||||
q = qualities(['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'])
|
||||
streaming_data = player_response.get('streamingData') or {}
|
||||
streaming_formats = streaming_data.get('formats') or []
|
||||
streaming_formats.extend(streaming_data.get('adaptiveFormats') or [])
|
||||
|
@ -1577,7 +1576,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||
'format_note': fmt.get('qualityLabel') or quality,
|
||||
'fps': int_or_none(fmt.get('fps')),
|
||||
'height': int_or_none(fmt.get('height')),
|
||||
# 'quality': q(quality), # TODO: Enable this after fixing formatSort
|
||||
'quality': q(quality),
|
||||
'tbr': tbr,
|
||||
'url': fmt_url,
|
||||
'width': fmt.get('width'),
|
||||
|
@ -1620,8 +1619,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||
itag = f['format_id']
|
||||
if itag in itags:
|
||||
continue
|
||||
# if itag in itag_qualities: # TODO: Enable this after fixing formatSort
|
||||
# f['quality'] = q(itag_qualities[itag])
|
||||
if itag in itag_qualities:
|
||||
# Not actually usefull since the sorting is already done with "quality,res,fps,codec"
|
||||
# but kept to maintain feature parity (and code similarity) with youtube-dl
|
||||
# Remove if this causes any issues with sorting in future
|
||||
f['quality'] = q(itag_qualities[itag])
|
||||
filesize = int_or_none(self._search_regex(
|
||||
r'/clen/(\d+)', f.get('fragment_base_url')
|
||||
or f['url'], 'file size', default=None))
|
||||
|
|
Loading…
Reference in a new issue