7

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?

2
  • So implementing via bot.send_document works, however it returns a timeout error
    – Vishnu U
    Dec 4, 2017 at 4:03
  • pass timeout=20 to the same method to override the default timeout, or even increase the number more
    – jeffffc
    Dec 5, 2017 at 5:40

1 Answer 1

5

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})

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.