尝试使用 PyTube 和 Tkinter 构建时出现正则表达式错误
Regex error when trying to build with PyTube and Tkinter
我在尝试 运行 此代码时遇到此错误。我想用 tkinter 和 pytube
构建一个 youtube 视频下载器
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()
这是因为您在 Button
作业中调用了 downloaderr
。
btn = Button(window,text= "Click to Download",command=downloaderr())
应该是
btn = Button(window,text= "Click to Download",command=downloaderr)
但是,当用户按下按钮时,您仍然会收到该错误。错误的原因是 videolink.get()
returns 与 pytube 所需的正则表达式模式不匹配。
我在尝试 运行 此代码时遇到此错误。我想用 tkinter 和 pytube
构建一个 youtube 视频下载器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()
这是因为您在 Button
作业中调用了 downloaderr
。
btn = Button(window,text= "Click to Download",command=downloaderr())
应该是
btn = Button(window,text= "Click to Download",command=downloaderr)
但是,当用户按下按钮时,您仍然会收到该错误。错误的原因是 videolink.get()
returns 与 pytube 所需的正则表达式模式不匹配。