尝试使用Pytube和TKINTER构建时的正则错误

发布于 2025-02-02 06:01:19 字数 683 浏览 2 评论 0原文

我在下面遇到此错误,试图运行此代码。我想使用tkinter和pytube pytube.exceptions.regexmatcherror构建YouTube视频下载器

:Regex_search:找不到匹配(?:v = | \/)([0-9a-Za-Za-Z _--] {11 })。*

from tkinter import *
from pytube import YouTube

window = Tk()

def downloaderr():
     yt = YouTube(videolink.get())
     yt.streams.first().download()


window.geometry('750x750')
window.title("YouTube Video Downloader")
lbl = Label(window,text="Video Linkini Yapıştırıp Butona Tıklayınız")
lbl.grid(column=5,row=10)
videolink = Entry(window,width=70)
videolink.grid
btn = Button(window,text= "Click to Download",command=downloaderr())
btn.grid(column=15,row=15) 
window.mainloop() 

I’m getting this error below trying to run this code. I want to build a youtube video downloader with tkinter and pytube

pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).*

from tkinter import *
from pytube import YouTube

window = Tk()

def downloaderr():
     yt = YouTube(videolink.get())
     yt.streams.first().download()


window.geometry('750x750')
window.title("YouTube Video Downloader")
lbl = Label(window,text="Video Linkini Yapıştırıp Butona Tıklayınız")
lbl.grid(column=5,row=10)
videolink = Entry(window,width=70)
videolink.grid
btn = Button(window,text= "Click to Download",command=downloaderr())
btn.grid(column=15,row=15) 
window.mainloop() 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

站稳脚跟 2025-02-09 06:01:19

这是因为您在button分配中调用下载

btn = Button(window,text= "Click to Download",command=downloaderr())

但是

btn = Button(window,text= "Click to Download",command=downloaderr)

,当用户按下按钮时,您仍然会遇到该错误。错误的原因是videoLink.get()返回不匹配Pytube所需的正则模式。

It's because you are calling the downloaderr in the Button assignment.

btn = Button(window,text= "Click to Download",command=downloaderr())

should be

btn = Button(window,text= "Click to Download",command=downloaderr)

However you will still get that error when a user presses the button. The reason for the error is whatever videolink.get() returns is not a match for the regex pattern required by pytube.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文