I tried to write a YouTube video downloader with choosen quality with Python
import pytube
from pytube import YouTube
videoURL = input("Enter Your Video Link : ")
videoRes = input ("Enter Your Quality : ")
try :
yt= YouTube(videoURL)
print ("Downloading...")
stream = yt.streams.filter(file_extension='mp4', resolution=videoRes).download(output_path="C:\\Users\\pc\\Desktop")
print("Download Successfully !")
except :
print("Please enter right link ")
And this is the Terminal output:
Enter Your Video Link : https://www.youtube.com/watch?v=0Ayf8Ij5cak
Enter Your Quality : 144p
Downloading...
Please enter right link
I resolved this error by adding the first()
method to the stream variable.
import pytube
from pytube import YouTube
videoURL = input("Enter Your Video Link : ")
videoRes = input ("Enter Your Quality : ")
try :
yt= YouTube(videoURL)
print ("Downloading...")
stream = yt.streams.filter(file_extension='mp4', resolution=videoRes).first().download(output_path="C:\\Users\\pc\\Desktop")
print("Download Successfully !")
except :
print("Please enter right link ")