import telebot import yt_dlp import os TOKEN = '8468827766:AAHnYY1BXQ2YFA0Lj86oTGG-GcXy3mOjXWo' bot = telebot.TeleBot(TOKEN) @bot.message_handler(commands=['start']) def start(message): bot.reply_to(message, "أهلاً يا محمد! ابعت أي رابط فيديو وهحملهولك فوراً.") @bot.message_handler(func=lambda m: True) def download_video(message): url = message.text msg = bot.reply_to(message, "⏳ جاري التحميل الفعلي للفيديو، انتظر لحظة...") # إعدادات التحميل ydl_opts = { 'format': 'best', 'outtmpl': 'video.mp4', 'quiet': True, } try: with yt_dlp.YoutubeDL(ydl_opts) as ydl: ydl.download([url]) # إرسال الفيديو بعد التحميل with open('video.mp4', 'rb') as video: bot.send_video(message.chat.id, video) # مسح الملف بعد الإرسال لتوفير المساحة os.remove('video.mp4') bot.delete_message(message.chat.id, msg.message_id) except Exception as e: bot.edit_message_text(f"❌ فشل التحميل. تأكد من الرابط أو جرب لاحقاً.", message.chat.id, msg.message_id) bot.infinity_polling()