Search code examples
pythonpython-3.xyoutubeurllib3pytube

HTTP Error404 in pytube


its supposed to be a youtube downloader, but whenever i try running the code i get "urllib.error.HTTPError: HTTP Error 404: Not Found " even though the url/link used is an valid url/link which is openable with any browser. ide used : pycharm v2021.1.3 & pytube v10.9.3

from pytube import YouTube
link = input("Enter Link Here : ")
url = YouTube(link)
print("Downloading....")
video = url.streams.first()
video.download()
print("Downloaded")

#alternate code

from pytube import YouTube

link = input("Enter Youtube URL : ")
yt = YouTube(link)
videos = yt.streams.all()
# this will stream all the format available for the video
video = list(enumerate(videos))
# this will be index all the format in list starting with zero
for i in video:
    print(i)
    # this will print all the available format of video with proper index
print("Enter the desired option to download the format")
dn_option = int(input("Enter the option : "))
# ask user that which format he want to download
dn_video = videos[dn_option]
dn_video.download()
# for downloading the video
print("Downloaded successfully")

Solution

  • My Error has been resolved it was pytube module who was having error If anybody sees HTTP error with any code use 2 testcases:

    Check the Link properly reinstall pytube (if pytube dosen't work install pytube3 but after uninstalling pytube) Thank you everyone !