How to build a YouTube Video Downloader Tool using Python

Here is a Python script that uses the 'pytube' library to download a YouTube video:

youtube video downloader python

from pytube import YouTube

url = input("Enter the YouTube video URL: ")
yt = YouTube(url)

# Select the video stream with the highest resolution
stream = yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first()

# Download the video to the current directory
stream.download()

print("Video downloaded successfully!")

You can also specify the download location by adding '.download(path)' to the last line, where 'path' is the directory path where you want to download the video.
I trust this helps you! if you have any query you can ask me.

Post a Comment