I am building a python project for the school (YouTube video downloader), but when I run it, it appears this error: urllib.error.HTTPError: HTTP Error 404: Not Found I have already tried other codes from other people and no one worked, I think is my computer. What can I do?
Here’s the code:
JavaScript
x
93
93
1
from tkinter import *
2
from tkinter import ttk
3
from tkinter import filedialog
4
from pytube import YouTube #pip install pytube3
5
6
Folder_Name = ""
7
8
#file location
9
def openLocation():
10
global Folder_Name
11
Folder_Name = filedialog.askdirectory()
12
if(len(Folder_Name) > 1):
13
locationError.config(text=Folder_Name,fg="green")
14
15
else:
16
locationError.config(text="Please Choose Folder!!",fg="red")
17
18
#donwload video
19
def DownloadVideo():
20
choice = ytdchoices.get()
21
url = ytdEntry.get()
22
23
if(len(url)>1):
24
ytdError.config(text="")
25
yt = YouTube(url)
26
27
if(choice == choices[0]):
28
select = yt.streams.filter(progressive=True).first()
29
30
elif(choice == choices[1]):
31
select = yt.streams.filter(progressive=True,file_extension='mp4').last()
32
33
elif(choice == choices[2]):
34
select = yt.streams.filter(only_audio=True).first()
35
36
else:
37
ytdError.config(text="Paste Link again!!",fg="red")
38
39
40
#download function
41
select.download(Folder_Name)
42
ytdError.config(text="Download Completed!!")
43
44
45
46
root = Tk()
47
root.title("YTD Downloader")
48
root.geometry("350x400") #set window
49
root.columnconfigure(0,weight=1)#set all content in center.
50
51
#Ytd Link Label
52
ytdLabel = Label(root,text="Enter the URL of the Video",font=("jost",15))
53
ytdLabel.grid()
54
55
#Entry Box
56
ytdEntryVar = StringVar()
57
ytdEntry = Entry(root,width=50,textvariable=ytdEntryVar)
58
ytdEntry.grid()
59
60
#Error Msg
61
ytdError = Label(root,text="Error Msg",fg="red",font=("jost",10))
62
ytdError.grid()
63
64
#Asking save file label
65
saveLabel = Label(root,text="Save the Video File",font=("jost",15,"bold"))
66
saveLabel.grid()
67
68
#btn of save file
69
saveEntry = Button(root,width=10,bg="red",fg="white",text="Choose Path",command=openLocation)
70
saveEntry.grid()
71
72
#Error Msg location
73
locationError = Label(root,text="Error Msg of Path",fg="red",font=("jost",10))
74
locationError.grid()
75
76
#Download Quality
77
ytdQuality = Label(root,text="Select Quality",font=("jost",15))
78
ytdQuality.grid()
79
80
#combobox
81
choices = ["720p","144p","Only Audio"]
82
ytdchoices = ttk.Combobox(root,values=choices)
83
ytdchoices.grid()
84
85
#donwload btn
86
downloadbtn = Button(root,text="Donwload",width=10,bg="red",fg="white",command=DownloadVideo)
87
downloadbtn.grid()
88
89
#developer Label
90
developerlabel = Label(root,text="Dream Developers",font=("jost",15))
91
developerlabel.grid()
92
root.mainloop()
93
And here is the terminal: Terminal
Advertisement
Answer
I tested: code doesn’t work with pytube-10.4.1
but works with the newest pytube-10.8.3
It seems YouTube
changed something on server and it needed changes in pytube
.