mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-04-28 17:15:57 +00:00
fix: yt: set cookies for check_size args (#35)
Co-authored-by: Aidan <aidan@p0ntus.com>
This commit is contained in:
parent
c6114c9f62
commit
7120644945
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user