@ReDeNDeR

Как прислать большие видео по telebot?

Как можно прислать большие видео по telebot? Я написал бота, который присылает видео он, работает с не болшыми видео но когда я присылаю 200 мб он показывает исключения.

Код:

import telebot

bot = telebot.TeleBot("TOKEN", parse_mode=None)

@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
    video = open('a.mp4', 'rb')
    bot.send_video(message.chat.id, video, timeout=100)

bot.polling()


Ошибка:

Traceback (most recent call last):
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1049, in _send_output
self.send(chunk)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 971, in send
self.sock.sendall(data)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1204, in sendall
v = self.send(byte_view[count:])
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1173, in send
return self._sslobj.write(data)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 410, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 392, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 1049, in _send_output
self.send(chunk)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\http\client.py", line 971, in send
self.sock.sendall(data)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1204, in sendall
v = self.send(byte_view[count:])
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\ssl.py", line 1173, in send
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Rasul\Desktop\Phposter\phposter.py", line 10, in
bot.polling()
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 455, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 513, in __threaded_polling
raise e
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 479, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 118, in raise_exceptions
raise self.exception_info
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 69, in run
task(*args, **kwargs)
File "C:\Users\Rasul\Desktop\Phposter\phposter.py", line 8, in send_welcome
bot.send_video(message.chat.id, video, timeout=10000)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 877, in send_video
apihelper.send_video(self.token, chat_id, data, duration, caption, reply_to_message_id, reply_markup,
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 521, in send_video
return _make_request(token, method_url, params=payload, files=files, method='post')
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 107, in _make_request
result = _get_req_session().request(
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Rasul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
  • Вопрос задан
  • 71 просмотр
Решения вопроса 1
@Inspector-Due
Если видео весит больше 50 МБ, то отправить видео,...
Но можно использовать MTProto API
К примеру, в Python есть библиотека pyrogram, которая позволяет отправлять файлы до 1.5 Gb
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы