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
1 changed files with 28 additions and 23 deletions
|
@ -41,7 +41,12 @@ const downloadFromYoutube = async (command, args) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getApproxSize = async (command, videoUrl) => {
|
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 {
|
try {
|
||||||
const { stdout } = await downloadFromYoutube(command, args);
|
const { stdout } = await downloadFromYoutube(command, args);
|
||||||
const sizeInBytes = parseInt(stdout.trim(), 10);
|
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);
|
await downloadFromYoutube(ffmpegPath, ffmpegArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +145,8 @@ module.exports = (bot) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ctx.replyWithVideo({
|
await ctx.replyWithVideo({
|
||||||
source: mp4File }, {
|
source: mp4File
|
||||||
|
}, {
|
||||||
caption: message,
|
caption: message,
|
||||||
parse_mode: 'Markdown',
|
parse_mode: 'Markdown',
|
||||||
reply_to_message_id: ctx.message.message_id,
|
reply_to_message_id: ctx.message.message_id,
|
||||||
|
@ -191,7 +197,6 @@ module.exports = (bot) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
|
||||||
const errMsg = Strings.ytDownload.uploadErr.replace("{error}", error)
|
const errMsg = Strings.ytDownload.uploadErr.replace("{error}", error)
|
||||||
await ctx.telegram.editMessageText(
|
await ctx.telegram.editMessageText(
|
||||||
ctx.chat.id,
|
ctx.chat.id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue