Home python Telebot and download video from Telegram

Telebot and download video from Telegram

Author

Date

Category

For small image processing tasks, you need to download video from TG on a wheelbarrow where the bot itself is twisted for further processing. To write a bot took all the praised Telebot. The documentation did not help in search of solving this issue. I can download anything but not video. Please tell me how to get the video in the same directory as for the launch of the bot. I give an example that I accumulated on the Internet but can not get file_id for video.

@ bot.message_handler (content_types = ['video'])
 Def Send_Text (Message):
 Bot.Send_Message (Message.chat.id, 'You sent me a video')
 File_info = Bot.Get_File (File_ID)
 Downloaded_file = Bot.Download_File (File_info.file_path)
 src = 'files /' + File_info.file_path
 With Open (SRC, 'WB') as new_file:
  new_file.write (downloaded_file)
bot.reply_to (Message, "Perhaps I will save it") `

Answer 1

Since the answers I have not been found to introduce the working function that downloaded the video from the user

@ bot.message_handler (content_types = ['video'])
Def Send_Text (Message):
Bot.Send_Message (Message.chat.id, 'You sent me a video')
File_info = Bot.Get_File (Message.Video.file_id)
Downloaded_file = Bot.Download_File (File_info.file_path)
src = file_info.file_path
With Open (SRC, 'WB') as new_file:
  new_file.write (downloaded_file)
bot.reply_to (Message, "Perhaps I Save it")

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions