使用 python 在 telegram bot 上上传超过 50mb 的视频

发布于 2025-01-20 13:00:26 字数 85 浏览 2 评论 0 原文

我只能将视频上传到50MB。 但是电报上的许多机器人可以将视频发送到2GB。 因此,我需要一个Python代码来将大型视频上传到Telegram Bot上。

I can only upload videos upto 50mb.
But many bots on telegram can send videos upto 2gb.
So,I need a Python code to upload large videos on telegram bot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜血缘 2025-01-27 13:00:26

首先,您需要自己开发机器人,其次,您可以使用 pyrogram 它使用 mtproto 可以帮助您绕过50MB限制。

这是pyrogram的一些虚拟代码,

## Send video by uploading from local file
await app.send_video("me", "video.mp4")

## Add caption to the video
await app.send_video("me", "video.mp4", caption="video caption")

## Send self-destructing video
await app.send_video("me", "video.mp4", ttl_seconds=10)

## Keep track of the progress while uploading
async def progress(current, total):
    print(f"{current * 100 / total:.1f}%")

await app.send_video("me", "video.mp4", progress=progress)

因为pyrogram是异步库,您需要对

first of all you need to develop the bot yourself and secondly you can use pyrogram it uses Mtproto which can help you bypass the 50MB limit.

Here's Some Dummy code from pyrogram

## Send video by uploading from local file
await app.send_video("me", "video.mp4")

## Add caption to the video
await app.send_video("me", "video.mp4", caption="video caption")

## Send self-destructing video
await app.send_video("me", "video.mp4", ttl_seconds=10)

## Keep track of the progress while uploading
async def progress(current, total):
    print(f"{current * 100 / total:.1f}%")

await app.send_video("me", "video.mp4", progress=progress)

As pyrogram is asynchronous library you need to be a little familiar with asyncio.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文