From faa76abbbd4da324fd9aa0c2d163c124c1c72f32 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Fri, 1 Jul 2022 00:51:30 -0400 Subject: [PATCH] Fixed issue where setting resolution in a sub would instead require that resolution to exist (#678 and #330) --- backend/downloader.js | 6 ++++-- backend/subscriptions.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/downloader.js b/backend/downloader.js index 56d2b35..b2d87c5 100644 --- a/backend/downloader.js +++ b/backend/downloader.js @@ -403,6 +403,8 @@ exports.generateArgs = async (url, type, options, user_uid = null, simulated = f // video-specific args const selectedHeight = options.selectedHeight; + const maxHeight = options.maxHeight; + const heightParam = selectedHeight || maxHeight; // audio-specific args const maxBitrate = options.maxBitrate; @@ -423,8 +425,8 @@ exports.generateArgs = async (url, type, options, user_uid = null, simulated = f } else { if (customQualityConfiguration) { qualityPath = ['-f', customQualityConfiguration, '--merge-output-format', 'mp4']; - } else if (selectedHeight && selectedHeight !== '' && !is_audio) { - qualityPath = ['-f', `'(mp4)[height=${selectedHeight}]`]; + } else if (heightParam && heightParam !== '' && !is_audio) { + qualityPath = ['-f', `'(mp4)[height${maxHeight ? '<' : ''}=${heightParam}]`]; } else if (is_audio) { qualityPath = ['--audio-quality', maxBitrate ? maxBitrate : '0'] } diff --git a/backend/subscriptions.js b/backend/subscriptions.js index 9fd73c0..45e8071 100644 --- a/backend/subscriptions.js +++ b/backend/subscriptions.js @@ -313,7 +313,7 @@ function generateOptionsForSubscriptionDownload(sub, user_uid) { let default_output = config_api.getConfigItem('ytdl_default_file_output') ? config_api.getConfigItem('ytdl_default_file_output') : '%(title)s'; const base_download_options = { - selectedHeight: sub.maxQuality && sub.maxQuality !== 'best' ? sub.maxQuality : null, + maxHeight: sub.maxQuality && sub.maxQuality !== 'best' ? sub.maxQuality : null, customFileFolderPath: getAppendedBasePath(sub, basePath), customOutput: sub.custom_output ? `${sub.custom_output}` : `${default_output}`, customArchivePath: path.join(basePath, 'archives', sub.name),