Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send video through telegram python api

I want to send a video through the API, there are functions to send text, images, audio and documents. Is there a function to send videos or should I use this function to do so?

bot.send_document(chat_id=chat_id, document=open('tests/test.zip', 'rb'))

Is there an easier/more correct way?

like image 947
Vishnu U Avatar asked Aug 06 '26 15:08

Vishnu U


1 Answers

The same as with documents

bot.send_video(chat_id=update.message.chat_id, video=open('output.mp4', 'rb'), supports_streaming=True)

send_document can sometimes send video as an actual document file, unplayable in TG

send_video will always send video, playable in TG and also, passing supports_streaming=True will make TG allow to stream before downloading.

More references about send_video and other send_* you can look up at https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/bot.py

To avoid timeout for sending use updater = Updater(token='TOKEN', request_kwargs={'read_timeout': 1000, 'connect_timeout': 1000})

like image 55
Gleb S Avatar answered Aug 09 '26 22:08

Gleb S



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!