diff --git a/commands/utility/download.js b/commands/utility/download.js index 53e9228..96bda86 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -61,7 +61,12 @@ export default { if (format) { let qualitys = await new Promise((resolve, reject) => { - execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', url, '--print', '%()j'], (err, stdout, stderr) => { + const options = [url, '--print', '%()j']; + if (proxy) { + options.push('--proxy'); + options.push(proxy); + }; + execFile('./bin/yt-dlp', options, (err, stdout, stderr) => { if (err) { reject(stderr); } @@ -311,7 +316,12 @@ async function checkSize(url, format, args, interaction, tries = 0) { async function getVideoDescription(urlArg) { return await new Promise((resolve, reject) => { - execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', urlArg, '--no-warnings', '-O', '%(description)s'], (err, stdout, stderr) => { + const options = [urlArg, '--no-warnings', '-O', '%(description)s']; + if (proxy) { + options.push('--proxy'); + options.push(proxy); + }; + execFile('./bin/yt-dlp', options, (err, stdout, stderr) => { if (err) { reject(stderr); } diff --git a/utils/videos.js b/utils/videos.js index 87a5fcd..a0ebfbd 100644 --- a/utils/videos.js +++ b/utils/videos.js @@ -15,7 +15,12 @@ export default { }; async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) { await new Promise((resolve, reject) => { - execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', '-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'], (err, stdout, stderr) => { + const options = ['-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings']; + if (proxy) { + options.push('--proxy'); + options.push(proxy); + }; + execFile('./bin/yt-dlp', options, (err, stdout, stderr) => { if (err) { return reject(stderr); } @@ -99,7 +104,12 @@ async function getVideoCodec(input) { async function getVideoSize(urlArg, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) { return await new Promise((resolve, reject) => { - execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', urlArg, '-f', format, '--no-warnings', '-O', '%(filesize,filesize_approx)s'], (err, stdout, stderr) => { + const options = [urlArg, '-f', format, '--no-warnings', '-O', '%(filesize,filesize_approx)s']; + if (proxy) { + options.push('--proxy'); + options.push(proxy); + }; + execFile('./bin/yt-dlp', options, (err, stdout, stderr) => { if (err) { reject(stderr); }