1 535
Subscribers
+224 hours
+137 days
+3030 days
Posts Archive
1 535
First person send:
I love youHere : @SONIK_Teambot❤️ =================== اول شخص يرسل :
I love youHere : @SONIK_Teambot❤️
1 535
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, CallbackQuery
import yt_dlp
import os
api_id = "18820170"
api_hash = "41f29e770be2436e54e04d7034f29547"
bot_token = "5876374441:AAE9TFeH1v4leCHGdcRffArxP0FGDlZ4ukg"
app = Client("m", api_id=api_id, api_hash=api_hash, bot_token=bot_token)
def search_youtube(query):
search_url = f"ytsearch5:{query}"
ydl_opts = {
"format": "best",
"noplaylist": True,
"quiet": True,
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(search_url, download=False)
return info["entries"]
def download_youtube_video(video_url, user_id):
file_template = f"downloads/{user_id}.%(ext)s"
ydl_opts = {
"format": "best",
"outtmpl": file_template,
"restrictfilenames": True,
}
os.makedirs("downloads", exist_ok=True)
existing_file = next((f"downloads/{f}" for f in os.listdir("downloads") if f.startswith(str(user_id))), None)
if existing_file:
return existing_file
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(video_url, download=True)
file_path = ydl.prepare_filename(info)
return file_path
@app.on_message(filters.private & filters.text)
def handle_message(client, message):
user_id = message.from_user.id
query = message.text
message.reply_text("جار البحث عن الفيديوهات...")
try:
videos = search_youtube(query)
if not videos:
message.reply_text("لم يتم العثور على اي فيديوهات.")
return
buttons = []
info_message = ""
for i, video in enumerate(videos):
title = video.get("title", "غير معروف")
duration = video.get("duration", 0)
duration_minutes = duration // 60
duration_seconds = duration % 60
video_id = video.get("id")
info_message += f"{i + 1}- {title} \nالمدة: {duration_minutes}:{duration_seconds:02d}\n\n"
buttons.append([
InlineKeyboardButton(f"{title}", callback_data=f"download|{video_id}|{user_id}")
])
message.reply_text(
text=info_message,
reply_markup=InlineKeyboardMarkup(buttons),
)
# بتاعة gpt 😂
except Exception as e:
message.reply_text(f"حدث خطأ أثناء البحث: {e}")
@app.on_callback_query()
def handle_callback_query(client, callback_query: CallbackQuery):
data = callback_query.data
if data.startswith("download"):
_, video_id, user_id = data.split("|")
user_id = int(user_id)
video_url = f"https://www.youtube.com/watch?v={video_id}"
callback_query.message.edit_text("جار تحميل الفيديو...")
try:
file_path = download_youtube_video(video_url, user_id)
with open(file_path, "rb") as video:
callback_query.message.reply_video(video=video, caption="تم تحميل الفيديو بنجاح!")
os.remove(file_path)
except Exception as e:
callback_query.message.reply_text(f"حدث خطأ أثناء تحميل الفيديو: {e}")
if __name__ == "__main__":
print("البوت يعمل...")
app.run()
كود سيرش ع فيديوهات اليوتيوب وتحميلها
يعتبر اول كود بايثون اكتبه بنفسي 😂❤️1 535
متوفر ثغره ازي اخليك تجيب vps
3usd 💷ب 💷150ج ب عرض لحد يومين 💷 6 اسيا بحاجه اسمه بين و ثغر بخليك تجيب بدل vps واحد بخليك تجيب كتير #اقبل_وسيط_في_اي_معامله 😀 Dev : @o_a_m
