Compare commits

..

No commits in common. "de6e0dd3c7c31efd9984d1172c13febc452113d2" and "fb4db75f0932db309b8db9035ceb60afa07e9219" have entirely different histories.

3 changed files with 16 additions and 26 deletions

View file

@ -16,10 +16,10 @@ const Blacklists = db.Blacklists;
export default {
data: new SlashCommandBuilder()
.setName('tweet')
.setDescription('Send tweet from the bot twitter account. Please do not use it for advertisement and keep it english')
.setDescription('Send tweet from Haha yes twitter account. Please do not use it for advertisement and keep it english')
.addStringOption(option =>
option.setName('content')
.setDescription('!THIS IS NOT FEEDBACK! The content of the tweet you want to send me.')
.setDescription('The content of the tweet you want to send me.')
.setRequired(false))
.addAttachmentOption(option =>
option.setName('image')

View file

@ -49,6 +49,15 @@ export default {
return interaction.editReply({ content: '❌ This does not look like a valid url!', ephemeral: true });
}
const aproxFileSize = await utils.getVideoSize(url, format);
if (aproxFileSize > 100 && !args.compress) {
await interaction.followUp('Uh oh! The video you tried to download is larger than 100 mb! Try again with compression.', { ephemeral: true });
}
else if (aproxFileSize > 500) {
await interaction.followUp('Uh oh! The video you tried to download is larger than 500 mb!', { ephemeral: true });
}
if (format) {
let qualitys = await new Promise((resolve, reject) => {
exec(`./bin/yt-dlp "${url}" --print "%()j"`, (err, stdout, stderr) => {
@ -61,8 +70,8 @@ export default {
resolve(stdout);
});
});
qualitys = JSON.parse(qualitys);
const options = [];
qualitys.formats.forEach(f => {
@ -108,30 +117,11 @@ export default {
if (!interactionMenu.isSelectMenu()) return;
if (interactionMenu.customId === `downloadQuality${interaction.user.id}${interaction.id}`) {
await interactionMenu.deferReply({ ephemeral: false });
const aproxFileSize = await utils.getVideoSize(url, interactionMenu.values[0]);
if (aproxFileSize > 100 && !args.compress) {
await interaction.followUp('Uh oh! The video you tried to download is larger than 100 mb! Try again with compression.', { ephemeral: true });
}
else if (aproxFileSize > 500) {
await interaction.followUp('Uh oh! The video you tried to download is larger than 500 mb!', { ephemeral: true });
}
download(url, interactionMenu, interaction);
}
});
return;
}
const aproxFileSize = await utils.getVideoSize(url);
if (aproxFileSize > 100 && !args.compress) {
await interaction.followUp('Uh oh! The video you tried to download is larger than 100 mb! Try again with compression.', { ephemeral: true });
}
else if (aproxFileSize > 500) {
await interaction.followUp('Uh oh! The video you tried to download is larger than 500 mb!', { ephemeral: true });
}
download(url, interaction);
},
};

View file

@ -14,7 +14,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 --remux-video=mp4/webm/mov`, (err, stdout, stderr) => {
exec(`./bin/yt-dlp -f ${format} "${urlArg}" -o "${os.tmpdir()}/${output}.%(ext)s" --force-overwrites --no-playlist --remux-video=mp4/webm/mov`, (err, stdout, stderr) => {
if (err) {
reject(stderr);
}
@ -68,7 +68,7 @@ async function stringIsAValidurl(s) {
async function compressVideo(input, output, preset) {
await new Promise((resolve, reject) => {
exec(`./bin/HandBrakeCLI -i "${input}" -Z "${preset}" -o "${os.tmpdir()}/${output}"`, (err, stdout, stderr) => {
exec(`./bin/HandBrakeCLI -i '${input}' -Z '${preset}' -o '${os.tmpdir()}/${output}'`, (err, stdout, stderr) => {
if (err) {
reject(stderr);
}
@ -82,7 +82,7 @@ async function compressVideo(input, output, preset) {
}
async function getVideoCodec(input) {
return await new Promise((resolve, reject) => {
exec(`ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "${input}"`, (err, stdout, stderr) => {
exec(`ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 ${input}`, (err, stdout, stderr) => {
if (err) {
reject(stderr);
}
@ -96,7 +96,7 @@ async function getVideoCodec(input) {
async function getVideoSize(urlArg, format = 'bestvideo*+bestaudio/best') {
return await new Promise((resolve, reject) => {
exec(`./bin/yt-dlp "${urlArg}" -f "${format}" -O "%(filesize,filesize_approx)s"`, (err, stdout, stderr) => {
exec(`./bin/yt-dlp ${urlArg} -f ${format} -O "%(filesize,filesize_approx)s"`, (err, stdout, stderr) => {
if (err) {
reject(stderr);
}