Fix some downloads

This commit is contained in:
supositware 2022-07-06 18:52:44 +02:00
parent 8f7afa9be7
commit 50aecd546a
2 changed files with 9 additions and 9 deletions

View file

@ -29,7 +29,7 @@ export default {
if (interaction.options.getBoolean('advanced')) { if (interaction.options.getBoolean('advanced')) {
let qualitys = await new Promise((resolve, reject) => { 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) { if (err) {
reject(stderr); reject(stderr);
} }
@ -45,12 +45,17 @@ export default {
qualitys.formats.forEach(f => { qualitys.formats.forEach(f => {
options.push({ options.push({
label: f.resolution, label: f.resolution ? f.resolution : 'Unknown format',
description: `${f.format} V: ${f.vcodec} A: ${f.acodec}`, description: `${f.format} V: ${f.vcodec} A: ${f.acodec}`,
value: f.format_id, 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) { if (options.length > 25) {
// Reverse so the higher quality formats are first // Reverse so the higher quality formats are first
options.reverse(); options.reverse();
@ -62,11 +67,6 @@ export default {
options.reverse(); 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() const row = new MessageActionRow()
.addComponents( .addComponents(
new MessageSelectMenu() new MessageSelectMenu()

View file

@ -9,7 +9,7 @@ export default {
}; };
async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') { async function downloadVideo(urlArg, output, format = 'bestvideo*+bestaudio/best') {
await new Promise((resolve, reject) => { 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) { if (err) {
reject(stderr); reject(stderr);
} }