fix: yt: set cookies for check_size args (#35)

Co-authored-by: Aidan <aidan@p0ntus.com>
This commit is contained in:
Giovani Finazzi 2025-04-14 21:59:11 -03:00 committed by GitHub
parent c6114c9f62
commit 7120644945
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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);
@ -140,7 +145,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,
@ -191,7 +197,6 @@ module.exports = (bot) => {
);
}
} catch (error) {
console.error(error);
const errMsg = Strings.ytDownload.uploadErr.replace("{error}", error)
await ctx.telegram.editMessageText(
ctx.chat.id,