'How can I send to download video above 50 mg in Telegram?

I create a telegram bot for downloading youtube videos. I use telegraf api (javascripts) and youtube-dl. As I know telegram bot can currently send video files of up to 50 MB in size, but I need to configure downloading more, e.g 1 gb. How I can do this, any ideas?

Code:

const { Telegraf } = require('telegraf');
const fs = require('fs');
const youtubedl = require('youtube-dl');

const bot = new Telegraf('mytoken');

var DOWN_URL = "https://www.youtube.com/watch?v=";
var TeleMaxData = 50;
var videosize;
let downloaded = 0

bot.command('/video', async (ctx) => {
    try {
        //let userID = ctx.from["id"];
        let videoURL = 'someYoutubeUrl';
        ctx.reply(`Youtube video URL: ${videoURL}`);

        var video = youtubedl(videoURL,
            ['--format=18'],
            { cwd: __dirname });

        video.on('info', function (info) {
            infor = info;
            ctx.reply('info', info)
            videosize = infor.size / 1000000;

            if (videosize < TeleMaxData) {
                ctx.reply('Download Started')
                video.pipe(fs.createWriteStream(`test.mp4`, { flags: 'a' }));

                video.on('end', async function () {
                    ctx.reply("Download completed");
                    try {
                        ctx.reply(`Download completed!\nVideo gets Send! - This might take a few Seconds! \n \n Title: \n ${infor.title}. It's ${videosize}mb big.`);
                        await ctx.replyWithVideo({
                            source: fs.createReadStream(`test.mp4`)
                        })
                    } catch (err) {
                        ctx.reply('Error: sendVideo' + err);
                    }
                })
            } else {
                ctx.reply(`The Video is ${videosize}mb. The maximum size for sending videos from Telegram is ${TeleMaxData}mb.`);
            }
        });
    } catch (err) {
        ctx.reply("ERROR" + err);
    }
})


Solution 1:[1]

I know some article, where person makes some agent who will upload file and bot just resend this message. This article in Russian, but i can translate some steps.

  1. You should go to https://core.telegram.org and following the instructions sign up your app
  2. You should receive api_id and api_hash

How it works?

  1. App working on server through BOT API make file for sending
  2. It invoke agent for downloading file on Telegram servers
  1. It receives file_id from agent
  2. Use this file

Btw, this person write on python, there some photos of his code, hope you will understand this. Sorry for my English, it's not perfect Link: https://habr.com/ru/post/348234/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kamelzhan Kairat