Skip to content

main.py#64

Open
Azizbek2oo8 wants to merge 1 commit into
aryanvikash:masterfrom
Azizbek2oo8:patch-3
Open

main.py#64
Azizbek2oo8 wants to merge 1 commit into
aryanvikash:masterfrom
Azizbek2oo8:patch-3

Conversation

@Azizbek2oo8

Copy link
Copy Markdown

from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, ContextTypes, filters
from pytube import YouTube

TOKEN = "8296126447:AAEuXrqw6A0SFl4qBPfK4E5QPlqKzXBeKjs" # <-- Bot tokenini kiriting

async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text("YouTube havolasini yuboring — men yuklab beraman.")

async def download_video(update: Update, context: ContextTypes.DEFAULT_TYPE):
url = update.message.text
try:
yt = YouTube(url)
stream = yt.streams.get_lowest_resolution()
video_path = stream.download()
await update.message.reply_video(video=open(video_path, "rb"))
except Exception as e:
await update.message.reply_text("Xatolik: " + str(e))

app = ApplicationBuilder().token(TOKEN).build()
app.add_handler(CommandHandler("start", start))
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, download_video))
app.run_polling()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants