from pytube import YouTube
# ask for the link from user
link =input("Enter the link of YouTube video you want to download: ")
yt = YouTube(link)# Showing detailsprint("Title: ", yt.title)print("Number of views: ", yt.views)print("Length of video: ", yt.length)print("Rating of video: ", yt.rating)# Getting the highest resolution possible
ys = yt.streams.get_highest_resolution()# Starting downloadprint("Downloading...")
ys.download()print("Download completed!!")
from pytube import YouTube
defDownload(link):
youtubeObject = YouTube(link)
youtubeObject = youtubeObject.streams.get_highest_resolution()try:
youtubeObject.download()except:print("An error has occurred")print("Download is completed successfully")
link =input("Enter the YouTube video URL: ")
Download(link)
from pytube import YouTube
#where to save
SAVE_PATH ="d:/"#to_do#link of the video to be downloaded
link=["https://www.youtube.com/watch?v=xWOoBJUqlbI","https://www.youtube.com/watch?v=xWOoBJUqlbI"]for i in link:try:# object creation using YouTube# which was imported in the beginning
yt = YouTube(i)except:#to handle exceptionprint("Connection Error")#filters out all the files with "mp4" extension
mp4files = yt.filter('mp4')# get the video with the extension and# resolution passed in the get() function
d_video = yt.get(mp4files[-1].extension,mp4files[-1].resolution)try:# downloading the video
d_video.download(SAVE_PATH)except:print("Some Error!")print('Task Completed!')