javascript - 如何在 Telegram 中发送下载 50 毫克以上的视频?
问题描述
我创建了一个电报机器人来下载 youtube 视频。我使用 telegraf api (javascripts) 和 youtube-dl。据我所知,电报机器人目前可以发送最大 50 MB 的视频文件,但我需要配置下载更多,例如 1 GB。我怎么能做到这一点,有什么想法吗?
代码:
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);
}
})
解决方案
推荐阅读
- powershell-5.0 - 如何仅解析 AbsoluteUri 和 LocalPath?
- amazon-web-services - Your WSGIPath refers to a file that does not exist while uploading flask app in AWS Elastic Beanstalk
- python - 验证列表中字符串的第一个字母是否为元音时出错,解决方案?
- jquery - 图像阵列的连续旋转
- angular8 - 在此元素上匹配多个组件
- javascript - Why does JavaScript returns that?
- python - Gradcam with guided backprop for transfer learning in Tensorflow 2.0
- javascript - return evaluated javascript function to terminal
- php - PHP 存储库模式 - 更新功能
- php - 从 php 文件中读取 auth.log 文件并将其显示在网页上