Compare commits
3 commits
fb4db75f09
...
de6e0dd3c7
Author | SHA1 | Date | |
---|---|---|---|
de6e0dd3c7 | |||
4e5324155d | |||
65eb5b997f |
3 changed files with 26 additions and 16 deletions
|
@ -16,10 +16,10 @@ const Blacklists = db.Blacklists;
|
|||
export default {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('tweet')
|
||||
.setDescription('Send tweet from Haha yes twitter account. Please do not use it for advertisement and keep it english')
|
||||
.setDescription('Send tweet from the bot twitter account. Please do not use it for advertisement and keep it english')
|
||||
.addStringOption(option =>
|
||||
option.setName('content')
|
||||
.setDescription('The content of the tweet you want to send me.')
|
||||
.setDescription('!THIS IS NOT FEEDBACK! The content of the tweet you want to send me.')
|
||||
.setRequired(false))
|
||||
.addAttachmentOption(option =>
|
||||
option.setName('image')
|
||||
|
|
|
@ -49,15 +49,6 @@ 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) => {
|
||||
|
@ -70,8 +61,8 @@ export default {
|
|||
resolve(stdout);
|
||||
});
|
||||
});
|
||||
qualitys = JSON.parse(qualitys);
|
||||
|
||||
qualitys = JSON.parse(qualitys);
|
||||
const options = [];
|
||||
|
||||
qualitys.formats.forEach(f => {
|
||||
|
@ -117,11 +108,30 @@ 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);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue