Electro
Активный участник
Возникла проблема при написании скрипта для загрузки видео с YouTube через бота в Telegram: появляется сообщение об ошибке 'get_throttling_function_name: could not find match for multiple'. Помощь требуется!"
Python:
import os
from aiogram import Bot, types, executor, Dispatcher
from pytube import YouTube
bot = Bot(token='')
dp = Dispatcher(bot)
def download_video(url):
yt = YouTube(url)
yt.streams.first().download(filename='temp_video')
return 'temp_video.mp4'
@dp.message_handler()
async def download_and_send(message: types.Message):
url = message.text
try:
video_path = download_video(url)
with open(video_path, 'rb') as video:
await bot.send_video(message.chat.id, video)
os.remove(video_path)
await bot.send_message(message.chat.id, "Видео успешно скачано и отправлено!")
except Exception as e:
await bot.send_message(message.chat.id, f"Произошла ошибка: {e}")
if __name__ == "__main__":
executor.start_polling(dp)