From b9f6d290610b409dc781060679686b5858e6fa1b Mon Sep 17 00:00:00 2001 From: controlol <46456214+controlol@users.noreply.github.com> Date: Thu, 4 Mar 2021 12:45:54 +0100 Subject: [PATCH 1/2] escape paths for use with commandline escape qualityPath and fullOutput for use with commandline In order to successfully download files from subscriptions these strings should be escaped to work properly in the commandline. I have seen you use almost the same function (generateArgs()) in app.js. Even though I have never had a problem with this outside subscriptions I would suggest to do the same for that function starting on line 1405 --- backend/subscriptions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/subscriptions.js b/backend/subscriptions.js index 3a6e0a3..5a0cd5d 100644 --- a/backend/subscriptions.js +++ b/backend/subscriptions.js @@ -366,11 +366,11 @@ async function generateArgsForSubscription(sub, user_uid, redownload = false, de let appendedBasePath = getAppendedBasePath(sub, basePath); - let fullOutput = `${appendedBasePath}/%(title)s.%(ext)s`; + let fullOutput = `'${appendedBasePath}/%(title)s.%(ext)s'`; if (desired_path) { - fullOutput = `${desired_path}.%(ext)s`; + fullOutput = `'${desired_path}.%(ext)s'`; } else if (sub.custom_output) { - fullOutput = `${appendedBasePath}/${sub.custom_output}.%(ext)s`; + fullOutput = `'${appendedBasePath}/${sub.custom_output}.%(ext)s'`; } let downloadConfig = ['-o', fullOutput, !redownload ? '-ciw' : '-ci', '--write-info-json', '--print-json']; @@ -381,8 +381,8 @@ async function generateArgsForSubscription(sub, user_uid, redownload = false, de qualityPath.push('-x'); qualityPath.push('--audio-format', 'mp3'); } else { - if (!sub.maxQuality || sub.maxQuality === 'best') qualityPath = ['-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4']; - else qualityPath = ['-f', `bestvideo[height<=${sub.maxQuality}]+bestaudio/best[height<=${sub.maxQuality}]`, '--merge-output-format', 'mp4']; + if (!sub.maxQuality || sub.maxQuality === 'best') qualityPath = ['-f', '\'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4\'']; + else qualityPath = ['-f', `'bestvideo[height<=${sub.maxQuality}]+bestaudio/best[height<=${sub.maxQuality}]'`, '--merge-output-format', 'mp4']; } downloadConfig.push(...qualityPath) From 7e9d1d30dae415c2264ba0a96e30aed49380c872 Mon Sep 17 00:00:00 2001 From: controlol <46456214+controlol@users.noreply.github.com> Date: Thu, 4 Mar 2021 13:46:39 +0100 Subject: [PATCH 2/2] patch qualityPath qualityPath should not be escaped, this results in `could not find format error` --- backend/subscriptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/subscriptions.js b/backend/subscriptions.js index 5a0cd5d..51b070a 100644 --- a/backend/subscriptions.js +++ b/backend/subscriptions.js @@ -381,8 +381,8 @@ async function generateArgsForSubscription(sub, user_uid, redownload = false, de qualityPath.push('-x'); qualityPath.push('--audio-format', 'mp3'); } else { - if (!sub.maxQuality || sub.maxQuality === 'best') qualityPath = ['-f', '\'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4\'']; - else qualityPath = ['-f', `'bestvideo[height<=${sub.maxQuality}]+bestaudio/best[height<=${sub.maxQuality}]'`, '--merge-output-format', 'mp4']; + if (!sub.maxQuality || sub.maxQuality === 'best') qualityPath = ['-f', 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4']; + else qualityPath = ['-f', `bestvideo[height<=${sub.maxQuality}]+bestaudio/best[height<=${sub.maxQuality}]`, '--merge-output-format', 'mp4']; } downloadConfig.push(...qualityPath)