mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-26 00:02:09 +00:00
fix: chooseFormat filtering improvements
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user