Fix download format

This commit is contained in:
Supositware 2024-08-31 15:44:31 +02:00
parent 126d29fdf9
commit 7926820e70

View file

@ -5,7 +5,7 @@ import os from 'node:os';
import path from 'node:path'; import path from 'node:path';
import { execFile } from 'node:child_process'; import { execFile } from 'node:child_process';
const { NODE_ENV } = process.env; const { NODE_ENV } = process.env;
const ytdlpFormat = 'bestvideo[height<=?480]/best';
export default { export default {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -63,14 +63,14 @@ export default {
return interaction.editReply({ content: '❌ This does not look like a valid url!', ephemeral: true }); return interaction.editReply({ content: '❌ This does not look like a valid url!', ephemeral: true });
} }
const aproxFileSize = await utils.getVideoSize(url, 'bestvideo[height<=?480]'); const aproxFileSize = await utils.getVideoSize(url, ytdlpFormat);
console.log(aproxFileSize); console.log(aproxFileSize);
if (aproxFileSize > 4) { if (aproxFileSize > 4) {
return interaction.editReply('The file you are trying to convert is too big! Limit is 4 MB'); return interaction.editReply('The file you are trying to convert is too big! Limit is 4 MB');
}; };
utils.downloadVideo(url, interaction.id, 'bestvideo[height<=?480]') utils.downloadVideo(url, interaction.id, ytdlpFormat)
.then(async () => { .then(async () => {
const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id)); const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id));
let output = `${os.tmpdir()}/${file}`; let output = `${os.tmpdir()}/${file}`;