fix: yt: set cookies for check_size args

This commit is contained in:
GiovaniFZ 2025-04-14 11:50:52 -03:00
parent ff9260bebc
commit 8ec088796e
No known key found for this signature in database
GPG key ID: 63DD92181B575322

View file

@ -41,7 +41,12 @@ const downloadFromYoutube = async (command, args) => {
};
const getApproxSize = async (command, videoUrl) => {
const args = [videoUrl, '--compat-opt', 'manifest-filesize-approx', '-O', 'filesize_approx'];
let args = [];
if (fs.existsSync(path.resolve(__dirname, "../props/cookies.txt"))) {
args = [videoUrl, '--compat-opt', 'manifest-filesize-approx', '-O', 'filesize_approx', '--cookies', path.resolve(__dirname, "../props/cookies.txt")];
} else {
args = [videoUrl, '--compat-opt', 'manifest-filesize-approx', '-O', 'filesize_approx'];
}
try {
const { stdout } = await downloadFromYoutube(command, args);
const sizeInBytes = parseInt(stdout.trim(), 10);
@ -117,7 +122,7 @@ module.exports = (bot) => {
},
);
if(fs.existsSync(tempMp4File)){
if (fs.existsSync(tempMp4File)) {
await downloadFromYoutube(ffmpegPath, ffmpegArgs);
}
@ -126,7 +131,8 @@ module.exports = (bot) => {
try {
await ctx.replyWithVideo({
source: mp4File }, {
source: mp4File
}, {
caption: message,
parse_mode: 'Markdown',
reply_to_message_id: ctx.message.message_id,
@ -177,7 +183,6 @@ module.exports = (bot) => {
);
}
} catch (error) {
console.error(error);
const errMsg = Strings.ytDownload.uploadErr.replace("{error}", error)
await ctx.telegram.editMessageText(
ctx.chat.id,