B
B
balak_in2021-02-17 20:22:24
Python
balak_in, 2021-02-17 20:22:24

Hello. How can I download a video sent to a telegram bot using python?

I want to download a video that a person will send to my telegram bot, nothing like this has been found on the Internet, maybe someone knows? Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex K, 2021-02-17
@alexk111

The algorithm is as follows:
1. In the Telegram object of the update that arrives as a message to the bot, check the presence of the `video` property for `message`
2. If it exists, we take `file_id` from it
3. Call the Telegram API `getFile` method, passing it ` file_id` from `video`
4. The method returns a file object that has a `file_path` property
5. Download the video from the link ` https://api.telegram.org/file/bot{token}/{file_path }`, where `{token}` is the bot token and `{file_path}` is the `file_path` from the file object obtained in step 4.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question