I need a Help with My Coding Error please!

I wants To Create a Telgram Bot which Basically Works Good and Download YouTube Videos, I writted Codes and Found error I was tried to Solve it By using Chat Got but it Not Resuls Good , Can You Guys See My code and Kindly Please Try to Solving It ???:

Repl link:

from pyrogram import Client, filters

API_ID = 'API ID' # Replace 'your_api_id' with your actual API ID
API_HASH = "API HASH" # Replace 'your_api_hash' with your actual API hash
BOT_TOKEN = 'Bot Token'  # Replace 'your_bot_token' with your actual bot token

app = Client(
    "youtube_downloader_bot",
    api_id=API_ID,
    api_hash=API_HASH,
    bot_token=BOT_TOKEN
)

#@app.on_message(filters.command("start"))
def start(client, message):
    message.reply_text("Welcome! Send me a YouTube video link to download.")


from pytube import YouTube

#@app.on_message(filters.text)
def echo(client, message):
    try:
        url = message.text
        yt = YouTube(url)
        video = yt.streams.filter(progressive=True, file_extension='mp4').first()
        video.download()
        message.reply_text("Video downloaded successfully!")
    except Exception as e:
        message.reply_text(f"An error occurred: {e}")


if __name__ == "__main__":
    app.run()

What kind of error are you facing?

2 Likes