Compare commits
2 commits
7ad4618dd0
...
64c45f87c0
Author | SHA1 | Date | |
---|---|---|---|
64c45f87c0 | |||
a5cc9c45ed |
3 changed files with 31 additions and 4 deletions
|
@ -61,7 +61,12 @@ export default {
|
|||
|
||||
if (format) {
|
||||
let qualitys = await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', url, '--print', '%()j'], (err, stdout, stderr) => {
|
||||
const options = [url, '--print', '%()j'];
|
||||
if (proxy) {
|
||||
options.push('--proxy');
|
||||
options.push(proxy);
|
||||
};
|
||||
execFile('./bin/yt-dlp', options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
|
@ -311,7 +316,12 @@ async function checkSize(url, format, args, interaction, tries = 0) {
|
|||
|
||||
async function getVideoDescription(urlArg) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', urlArg, '--no-warnings', '-O', '%(description)s'], (err, stdout, stderr) => {
|
||||
const options = [urlArg, '--no-warnings', '-O', '%(description)s'];
|
||||
if (proxy) {
|
||||
options.push('--proxy');
|
||||
options.push(proxy);
|
||||
};
|
||||
execFile('./bin/yt-dlp', options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,13 @@ export default {
|
|||
return interaction.editReply({ content: '❌ This does not look like a valid url!', ephemeral: true });
|
||||
}
|
||||
|
||||
const aproxFileSize = await utils.getVideoSize(url, 'bestvideo[height<=?480]');
|
||||
console.log(aproxFileSize);
|
||||
|
||||
if (aproxFileSize > 4) {
|
||||
return interaction.editReply('The file you are trying to convert is too big! Limit is 4 MB');
|
||||
};
|
||||
|
||||
utils.downloadVideo(url, interaction.id)
|
||||
.then(async () => {
|
||||
const file = fs.readdirSync(os.tmpdir()).filter(fn => fn.startsWith(interaction.id));
|
||||
|
|
|
@ -15,7 +15,12 @@ export default {
|
|||
};
|
||||
async function downloadVideo(urlArg, output, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
||||
await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', '-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'], (err, stdout, stderr) => {
|
||||
const options = ['-f', format, urlArg, '-o', `${os.tmpdir()}/${output}.%(ext)s`, '--force-overwrites', '--no-playlist', '--remux-video=mp4/webm/mov', '--no-warnings'];
|
||||
if (proxy) {
|
||||
options.push('--proxy');
|
||||
options.push(proxy);
|
||||
};
|
||||
execFile('./bin/yt-dlp', options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
return reject(stderr);
|
||||
}
|
||||
|
@ -99,7 +104,12 @@ async function getVideoCodec(input) {
|
|||
|
||||
async function getVideoSize(urlArg, format = `bestvideo[height<=?${ytdlpMaxResolution}]+bestaudio/best`) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
execFile('./bin/yt-dlp', [proxy ? '--proxy' : '', proxy ? proxy : '', urlArg, '-f', format, '--no-warnings', '-O', '%(filesize,filesize_approx)s'], (err, stdout, stderr) => {
|
||||
const options = [urlArg, '-f', format, '--no-warnings', '-O', '%(filesize,filesize_approx)s'];
|
||||
if (proxy) {
|
||||
options.push('--proxy');
|
||||
options.push(proxy);
|
||||
};
|
||||
execFile('./bin/yt-dlp', options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue