fix: chooseFormat filtering improvements

This commit is contained in:
Daniel Wykerd
2022-06-16 13:06:10 +02:00
committed by LuanRT
parent 41aa54b8d9
commit 60075f8726

View File

@@ -285,9 +285,16 @@ class VideoInfo {
});
}
if (is_best)
if (is_best && requires_video)
candidates = candidates.filter(format => format.width === best_width);
if (requires_audio && !requires_video) {
const audio_only = candidates.filter(format => !format.has_video);
if (audio_only.length > 0) {
candidates = audio_only;
}
}
if (use_most_efficient)
// sort by bitrate (lower is better)
candidates.sort((a, b) => a.bitrate - b.bitrate);
@@ -303,7 +310,7 @@ class VideoInfo {
* @param {object} options - download options.
* @param {string} [options.quality] - video quality; 360p, 720p, 1080p, etc... also accepts 'best' and 'bestefficiency'.
* @param {string} [options.type] - download type, can be: video, audio or videoandaudio
* @param {string} [options.format] - file format
* @param {string} [options.format] - file format, use 'any' to download any format.
* @param {object} [options.range] - download range, indicates which bytes should be downloaded.
* @param {number} options.range.start - the beginning of the range.
* @param {number} options.range.end - the end of the range.