Youtube Downloader using Python
-
Step 1: Download library
pip install pytube3
This will download the library
-
Step 2: Import library
from pytube import YouTube
This will import the library
-
Step 3: Accept input from user
link = input("Enter the link: ") yt = YouTube(link)
-
Step 4: Display video information
# Title of the video print(f"Title: {yt.title}") # Number of views print(f"Views: {yt.views}") # Length of the video print(f"Duration: {yt.length}") # Description print(f"Description: {yt.description}")
This will display more information about video.
-
Step 5: Check for available streams
print(yt.streams)
-
Step 6: Check for Highest Quality
print(yt.streams.filter(progressive=True)) ys = yt.streams.get_highest_resolution()
-
Step 7: Download video
ys.download() print("Download completed !!")
Example Source Code
from pytube import YouTube
link = input("Enter the link: ")
yt = YouTube(link)
# Title of the video
print(f"Title: {yt.title}")
# Number of views
print(f"Views: {yt.views}")
# Length of the video
print(f"Duration: {yt.length}")
# Description
print(f"Description: {yt.description}")
# Available Streams
print(yt.streams)
print(yt.streams.filter(progressive=True))
ys = yt.streams.get_highest_resolution()
ys.download()
print("Download completed !!")