fix: yt: set cookies for check_size args #35
1 changed files with 28 additions and 23 deletions
|
@ -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);
|
||||
|
@ -131,7 +136,7 @@ module.exports = (bot) => {
|
|||
},
|
||||
);
|
||||
|
||||
if(fs.existsSync(tempMp4File)){
|
||||
if (fs.existsSync(tempMp4File)) {
|
||||
await downloadFromYoutube(ffmpegPath, ffmpegArgs);
|
||||
}
|
||||
|
||||
|
@ -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…
Add table
Add a link
Reference in a new issue