im working on a Youtube Downloader with pytube and dearpygui (dpg) right now.
While trying to fuse the GUI with the rest of the Code i ran into Issues with pytube.
Error Code:
Traceback (most recent call last):
File "c:\Users\mitja\Documents\ytdownload\ytdownloadGUI.py", line 25, in downloadbutton
yt = YouTube(videolink)
^^^^^^^^^^^^^^^^^^
File "C:\Users\mitja\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\__main__.py", line 71, in __init__
self.video_id = extract.video_id(url)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitja\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\extract.py", line 133, in video_id
return regex_search(r"(?:v=|\/)([0-9A-Za-z_-]{11}).*", url, group=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\mitja\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\helpers.py", line 129, in regex_search
raise RegexMatchError(caller="regex_search", pattern=pattern)
pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|\/)([0-9A-Za-z_-]{11}).*
The the parts of the Code that produce the error are:
videolink = ''
def link(Sender, Data):
videolink = dpg.get_value(24)
print(videolink)
dpg.add_input_text(label="Video Link", hint="youtube.com/", callback=link)
Could it be that the Text that i extract from dpg is in the wrong format for pytube?
I already tried to make it a raw string etc.
I have found nothing on google and here on Stackoverflow too.
Does someone know how to format the link so that pytube can use it?
Yes, the way your link() function is called is incorrect, you have not referred properly for dgp.get_value()
make sure to keep the s in sender small, and I am assuming you referred to 24 as the size you required,
This code will continuously print the videolink, for optimizing for printing only when pressed enter try this:
This would call the function when you pressed enter and would print the text
Similarly, you can trigger it by a button too.