Spaces:
Runtime error
Runtime error
File size: 1,296 Bytes
9c59a03 8b60ace 9c59a03 8b60ace 9c59a03 8b60ace 9c59a03 8b60ace ff61e50 8b60ace 9c59a03 8b60ace 9c59a03 8b60ace 7e5bace 8b60ace 9c59a03 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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()
|