尝试使用pytube时,Tkinter回调出现异常



当尝试使用我制作的视频下载程序时,我不断收到一个错误。我已经看了很多其他问题,试图找到解决方案,但这几乎就像我是唯一一个有这个问题的

附件是错误和我的代码

import pytube
import tkinter
from tkinter import *
from pytube import YouTube

root = Tk()
root.geometry('500x300')
root.resizable(0,0)
root.title("DataFlair-youtube video downloader")


Label(root,text = 'Youtube Video Downloader', font ='arial 20 bold').pack()

link = StringVar()

Label(root, text = 'Paste Link Here:', font = 'arial 15 bold').place(x= 160 , y = 60)
link_enter = Entry(root, width = 70,textvariable = link).place(x = 32, y = 90)


def Downloader():

url =YouTube(str(link.get()))
video = url.streams.first()
video.download()
Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y = 210)  


Button(root,text = 'DOWNLOAD', font = 'arial 15 bold' ,bg = 'pale violet red', padx = 2, command = Downloader).place(x=180 ,y = 150)



root.mainloop()
Exception in Tkinter callback Traceback (most recent call last):   File "C:UsersOwnerAppDataLocalProgramsPythonPython39libtkinter__init__.py", line 1884, in __call__
return self.func(*args)   File "c:UsersOwnerDownloadsyoutube_download.py", line 22, in Downloader
url =YouTube(str(link.get()))   File "C:UsersOwnerAppDataLocalProgramsPythonPython39libsite-packagespytube__main__.py", line 91, in __init__
self.prefetch()   File "C:UsersOwnerAppDataLocalProgramsPythonPython39libsite-packagespytube__main__.py", line 181, in prefetch
self.vid_info_raw = request.get(self.vid_info_url)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39libsite-packagespytuberequest.py", line 36, in get
return _execute_request(url).read().decode("utf-8")   File "C:UsersOwnerAppDataLocalProgramsPythonPython39libsite-packagespytuberequest.py", line 24, in _execute_request
return urlopen(request)  # nosec   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 214, in urlopen
return opener.open(url, data, timeout)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 523, in open
response = meth(req, response)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 632, in http_response
response = self.parent.error(   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 555, in error
result = self._call_chain(*args)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 494, in _call_chain
result = func(*args)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 747, in http_error_302
return self.parent.open(new, timeout=req.timeout)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 523, in open
response = meth(req, response)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 632, in http_response
response = self.parent.error(   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 561, in error
return self._call_chain(*args)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 494, in _call_chain
result = func(*args)   File "C:UsersOwnerAppDataLocalProgramsPythonPython39liburllibrequest.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 404: Not Found

其他人也面临着与pytube相同的问题。您可能需要在此处查看解决方案。堆栈溢出问题

使用Pytube10.8.3运行时出现错误404,但它与最新的10.8.5一起工作

YouTube有时会对页面进行更改,PyTube可能也需要更新。

最新更新