dl: Add cookie file
All checks were successful
CI / CI (push) Successful in 1m24s

This commit is contained in:
SileNce5k 2025-06-18 00:14:10 +02:00
parent 0a35549666
commit 340727ae60
Signed by: SileNce
GPG key ID: B0A142BB4291B204

View file

@ -10,6 +10,7 @@ module.exports = {
], ],
async execute({message, args}) { async execute({message, args}) {
const downloadsDir = path.resolve(process.cwd(), 'data', 'downloads', Math.floor(new Date).toString()); const downloadsDir = path.resolve(process.cwd(), 'data', 'downloads', Math.floor(new Date).toString());
const cookieFilepath = path.resolve(process.cwd(), 'data', 'cookies.txt')
fs.mkdirSync(downloadsDir, {recursive: true}); fs.mkdirSync(downloadsDir, {recursive: true});
let url; let url;
@ -28,13 +29,13 @@ module.exports = {
return message.channel.send("No url provided") return message.channel.send("No url provided")
} }
if(this.executeCommand(`yt-dlp "${url}" -P ${downloadsDir}`).error){ if(this.executeCommand(`yt-dlp "${url}" -P ${downloadsDir} --cookies ${cookieFilepath}`).error){
message.channel.send("An error occured when executing the command"); message.channel.send("An error occured when executing the command");
this.cleanUp(downloadsDir); this.cleanUp(downloadsDir);
return; return;
} }
let files = fs.readdirSync(downloadsDir); let files = fs.readdirSync(downloadsDir);
if(files < 1) { if(files < 1) {
this.cleanUp(downloadsDir); this.cleanUp(downloadsDir);