У меня есть код для телеграмм бота
import telebot
import random
from pytube import YouTube
import os
from telebot import types
bot = telebot.TeleBot('Я это скрою')
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id, "Добро пожаловать! Скинь ссылку мне и я тебе скачаю видео из YouTube.".format(message.from_user, bot.get_me()))
@bot.message_handler(content_types=['text'])
def lalala(message):
url = message.text;
ytvideo=YouTube('https://www.youtube.com/watch?v=6UsmxqqsBsM').streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()
ytvideo.download("./xvideo")
for file in os.listdir("./xvideo"):
if file.endswith(".mp4"):
videopas = os.path.join("./xvideo", file)
video = open(videopas, 'rb')
bot.send_video(message.chat.id, video)
# RUN
bot.polling(none_stop=True)
Но он выдаёт ошибку
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\79857\Desktop\DowloaderYoutubeBot\DowloaderYoutubeBot.py", line 26, in <module>
bot.polling(none_stop=True)
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 427, in polling
self.__threaded_polling(none_stop, interval, timeout)
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 451, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 118, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\six.py", line 703, in reraise
raise value
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 69, in run
task(*args, **kwargs)
File "C:\Users\79857\Desktop\DowloaderYoutubeBot\DowloaderYoutubeBot.py", line 23, in lalala
bot.send_video(message.chat.id, video)
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 807, in send_video
apihelper.send_video(self.token, chat_id, data, duration, caption, reply_to_message_id, reply_markup,
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\apihelper.py", line 511, in send_video
return _make_request(token, method_url, params=payload, files=files, method='post')
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\apihelper.py", line 102, in _make_request
result = _get_req_session().request(
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Users\79857\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\adapters.py", line 415, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', timeout('The write operation timed out'))
Пожалуйста помогите, в чём проблема?
Буду сердечно блогадаренн!!