diff --git a/commands/utility/download.js b/commands/utility/download.js index 6e4194b..cc44c2b 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -29,7 +29,7 @@ export default { if (interaction.options.getBoolean('advanced')) { let qualitys = await new Promise((resolve, reject) => { - exec(`./bin/yt-dlp ${url} --print "%()j"`, (err, stdout, stderr) => { + exec(`./bin/yt-dlp "${url}" --print "%()j"`, (err, stdout, stderr) => { if (err) { reject(stderr); } @@ -45,12 +45,17 @@ export default { qualitys.formats.forEach(f => { options.push({ - label: f.resolution, + label: f.resolution ? f.resolution : 'Unknown format', description: `${f.format} V: ${f.vcodec} A: ${f.acodec}`, value: f.format_id, }); }); + if (options.length < 2) { + await interaction.deleteReply(); + return interaction.followUp({ content: '❌ There is no other quality option for this video!', ephemeral: true }); + } + if (options.length > 25) { // Reverse so the higher quality formats are first options.reverse(); @@ -62,11 +67,6 @@ export default { options.reverse(); } - if (options.length < 2) { - await interaction.deleteReply(); - return interaction.followUp({ content: '❌ There is no other quality option for this video!', ephemeral: true }); - } - const row = new MessageActionRow() .addComponents( new MessageSelectMenu() diff --git a/utils/videos.js b/utils/videos.js index fbfbadf..77c653f 100644 --- a/utils/videos.js +++ b/utils/videos.js @@ -9,7 +9,7 @@ export default { }; async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') { await new Promise((resolve, reject) => { - exec(`./bin/yt-dlp -f ${format} ${urlArg} -o "${os.tmpdir()}/${output}.%(ext)s" --force-overwrites --no-playlist`, (err, stdout, stderr) => { + exec(`./bin/yt-dlp -f ${format} "${urlArg}" -o "${os.tmpdir()}/${output}.%(ext)s" --force-overwrites --no-playlist`, (err, stdout, stderr) => { if (err) { reject(stderr); } @@ -57,4 +57,4 @@ async function stringIsAValidurl(s) { catch (err) { return false; } -} \ No newline at end of file +}