为什么 pytube 在下载 youtube 视频时抛出错误

Why is pytube throwing error when downloading youtube video

编辑下方

当前版本的 pytube 不再工作。 Youtube居然做了一个防止自动视频下载的好方法,令人震惊...

另一次编辑 没关系,有一个简单的绕过。在 pytube 目录中,有一个名为 cipher.py 的文件。目前,在 pytube 11.0.2 中,密码文件有一个 cipher class 和一个 init 函数。在函数中,有一个名为regex 的变量。确保分配给re.compile(r"^$*\w+\W"),问题就解决了。

我收到此错误 pytube.exceptions.RegexMatchError: __init__: could not find match for ^\w+\W\n,

当我 运行:

时出现此错误
YouTube(url).streams.get_by_resolution(res).download(output_path="public/videos/",filename=endUrl + ".mp4")

无论我使用什么 YouTube 视频 url,我都会收到此错误,并且我确保我尝试下载的视频与我的 'res' 变量兼容。 上面的代码 运行 由于某些令人沮丧的原因直到今天都完美无缺。我正在 运行 最新版本的 pytube。

在 pytube 目录中,有一个名为 cipher.py 的文件。目前,在 pytube 11.0.2 中,密码文件有一个带有初始化函数的密码 class。在函数中,有一个名为regex 的变量。确保分配给re.compile(r"^$*\w+\W"),问题就解决了。