From 28c2c2b649e3e04667c4a95fffb8cd1b48c04b93 Mon Sep 17 00:00:00 2001 From: Giovani Finazzi <53719063+GiovaniFZ@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:01:10 -0300 Subject: [PATCH] fix: try to fix yt-dlp command (#24) * gitgnore: Don't commit plugins * youtube: fix for command w/o cookies --- .gitignore | 1 + src/commands/youtube.js | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 9a2b4ef..4cb2983 100644 --- a/.gitignore +++ b/.gitignore @@ -137,6 +137,7 @@ lastfm.json sw-blocklist.txt package-lock.json tmp/ +plugins/ # Executables *.exe diff --git a/src/commands/youtube.js b/src/commands/youtube.js index 8fe4dea..f35cf73 100644 --- a/src/commands/youtube.js +++ b/src/commands/youtube.js @@ -63,20 +63,18 @@ module.exports = (bot) => { const videoUrl = ctx.message.text.split(' ').slice(1).join(' '); let cookieFlag = ""; - if (fs.existsSync(path.resolve(__dirname, "../props/cookies.txt"))) { - cookieFlag = "--cookies src/props/cookies.txt"; - } else { - cookieFlag = ""; - }; - const mp4File = `tmp/${userId}.mp4`; const tempMp4File = `tmp/${userId}.f137.mp4`; const tempWebmFile = `tmp/${userId}.f251.webm`; - const cmdArgs = `--max-filesize 2G --no-playlist ${cookieFlag} --merge-output-format mp4 -o`; + let cmdArgs = `--max-filesize 2G --no-playlist --merge-output-format mp4 -o`; const dlpCommand = ytDlpPath; const ffmpegPath = getFfmpegPath(); const ffmpegArgs = ['-i', tempMp4File, '-i', tempWebmFile, '-c:v copy -c:a copy -strict -2', mp4File]; + if (fs.existsSync(path.resolve(__dirname, "../props/cookies.txt"))) { + cmdArgs = "--max-filesize 2G --no-playlist --cookies src/props/cookies.txt --merge-output-format mp4 -o"; + } + try { const downloadingMessage = await ctx.reply(Strings.ytCheckingSize, { parse_mode: 'Markdown',