forked from Supositware/Haha-Yes
Use --rm-cache-dir when downloading a video
This commit is contained in:
parent
72d474f06a
commit
133538dbe9
2 changed files with 7 additions and 7 deletions
|
@ -3,6 +3,8 @@ const YTPGenerator = require('ytpplus-node');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const youtubedl = require('youtube-dl');
|
const youtubedl = require('youtube-dl');
|
||||||
|
const MAX_CLIPS = 20;
|
||||||
|
|
||||||
|
|
||||||
class ytpCommand extends Command {
|
class ytpCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -100,8 +102,6 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let MAX_CLIPS = 20;
|
|
||||||
|
|
||||||
if (args.pool) {
|
if (args.pool) {
|
||||||
let mp4 = [];
|
let mp4 = [];
|
||||||
fs.readdirSync('./asset/ytp/userVid/').forEach(file => {
|
fs.readdirSync('./asset/ytp/userVid/').forEach(file => {
|
||||||
|
@ -123,7 +123,7 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
return youtubedl.exec(url, ['--no-playlist','--max-filesize', '50m', '--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err, output) {
|
return youtubedl.exec(url, ['--rm-cache-dir', '--no-playlist', '--max-filesize', '50m', '--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err, output) {
|
||||||
console.log(output);
|
console.log(output);
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
|
@ -69,10 +69,10 @@ class DownloadCommand extends Command {
|
||||||
|
|
||||||
if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
|
if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
|
||||||
fs.unlink(`${os.tmpdir()}/${fileName}`, (err) => {
|
fs.unlink(`${os.tmpdir()}/${fileName}`, (err) => {
|
||||||
if (err);
|
if (err) console.error(err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return youtubedl.exec(link, ['-o', `${os.tmpdir()}/${fileName}`], {}, async function(err) {
|
return youtubedl.exec(link, ['--rm-cache-dir', '-o', `${os.tmpdir()}/${fileName}`], {}, async function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
|
@ -84,7 +84,7 @@ class DownloadCommand extends Command {
|
||||||
if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
|
if (fs.existsSync(`${os.tmpdir()}/${fileName}`)) {
|
||||||
ext = await filetype.fromFile(`${os.tmpdir()}/${fileName}`);
|
ext = await filetype.fromFile(`${os.tmpdir()}/${fileName}`);
|
||||||
ext = ext.ext; // This look stupid but hey, it work
|
ext = ext.ext; // This look stupid but hey, it work
|
||||||
if (ext == '3gp') ext = 'mp4'; // Change 3gp file extension to mp4 so discord show the video ( and to stop people from complaining )
|
if (ext === '3gp') ext = 'mp4'; // Change 3gp file extension to mp4 so discord show the video ( and to stop people from complaining )
|
||||||
fs.renameSync(`${os.tmpdir()}/${fileName}`, `${os.tmpdir()}/${fileName}.${ext}`);
|
fs.renameSync(`${os.tmpdir()}/${fileName}`, `${os.tmpdir()}/${fileName}.${ext}`);
|
||||||
} else if (fs.existsSync(`${os.tmpdir()}/${fileName}.mkv`)) { // If it can't find the video assume it got merged and end with mkv
|
} else if (fs.existsSync(`${os.tmpdir()}/${fileName}.mkv`)) { // If it can't find the video assume it got merged and end with mkv
|
||||||
fs.renameSync(`${os.tmpdir()}/${fileName}.mkv`, `${os.tmpdir()}/${fileName}.mp4`); // Discord play mkv just fine but it need to end with mp4
|
fs.renameSync(`${os.tmpdir()}/${fileName}.mkv`, `${os.tmpdir()}/${fileName}.mp4`); // Discord play mkv just fine but it need to end with mp4
|
||||||
|
@ -125,7 +125,7 @@ class DownloadCommand extends Command {
|
||||||
|
|
||||||
// Every 5 seconds update the compress message with the %
|
// Every 5 seconds update the compress message with the %
|
||||||
let editmsg = setInterval(() => {
|
let editmsg = setInterval(() => {
|
||||||
compressEmbed.setDescription(`Ready in ${eta == '' ? 'soon enough' : eta}. ${percentComplete}% complete.`);
|
compressEmbed.setDescription(`Ready in ${eta === '' ? 'soon enough' : eta}. ${percentComplete}% complete.`);
|
||||||
compressmsg.edit(compressEmbed);
|
compressmsg.edit(compressEmbed);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue