Why is pytube throwing error when downloading youtube video

EDIT BELOW

The current version of pytube does not work anymore. Youtube actually made a good way of preventing automated video downloads, shocker...

ANOTHER EDIT Nevermind, there is an easy bypass. In the pytube directory, there is a file called cipher.py. Currently, in pytube 11.0.2, the cipher file has a cipher class with an init function. In the function, there is a variable called regex. Make sure that it is assigned to re.compile(r"^$*\w+\W") and the problem will be fixed.

I am getting this error pytube.exceptions.RegexMatchError: __init__: could not find match for ^\\w+\\W\n,

I get this error when I run:

YouTube(url).streams.get_by_resolution(res).download(output_path="public/videos/",filename=endUrl + ".mp4")

I get this error no matter what YouTube video url I use and I make sure the video I am trying to download is compatible with my 'res' variable. The code above ran perfectly until today for some frustrating reason. I am running the latest version of pytube.


In the pytube directory, there is a file called cipher.py. Currently, in pytube 11.0.2, the cipher file has a cipher class with an init function. In the function, there is a variable called regex. Make sure that it is assigned to re.compile(r"^$*\w+\W") and the problem will be fixed.