Home > Enterprise >  Regex error when trying to build with PyTube and Tkinter
Regex error when trying to build with PyTube and Tkinter

Time:05-29

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() 

CodePudding user response:

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.

  • Related