我习惯用以下方式下载歌曲:
from pytube import YouTube
video = YouTube('https://www.youtube.com/watch?v=AWXvSBHB210')
video.streams.get_by_itag(251).download()
字符串
从今天起,就有了这个错误:
Traceback (most recent call last):
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 170, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 278, in get_throttling_function_name
raise RegexMatchError(
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Me\Documents\YouTubeDownloader.py", line 3, in <module>
video.streams.get_by_itag(251).download()
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 285, in streams
return StreamQuery(self.fmt_streams)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py", line 278, in get_throttling_function_name
raise RegexMatchError(
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
型
8条答案
按热度按时间6za6bjd01#
因为youtube在它的一端做了一些更改,现在你必须将pytube的cipher.py的
get_throttling_function_name
变量function_patterns
更改为下面的内容字符串
第288行也要改成这样:
型
在pytube正式发布修复之前,您必须使用此解决方案。
编辑:这很可能在未来youtube更新他们的网站时再次被打破,请务必检查github的问题以获得可能的解决方案
pcrecxhr2#
我在使用pytube 11.0.0时遇到了同样的问题
所以发现cipher.py类中的pytube库中存在正则表达式过滤器不匹配
字符串
现在有一个pytube代码昨天更新到11.0.1
型
有了这个代码更新现在下载youtube视频与pytube工程!!!
使用以下命令更新你的pytube库:
型
nbewdwxp3#
用这个更新你的(cipher.py -> get_throttling_function_name -> function_patterns),然后它就可以工作了。
字符串
nnvyjq4y4#
在Pytube版本15.0.0中,您只需要删除
cipher.py
文件第287行中的;
。将
r'var {nfunc}\s*=\s*(\[.+?\];)'.format(
更改为r'var {nfunc}\s*=\s*(\[.+?\])'.format(
5rgfhyps5#
更新的正则表达式:
字符串
如果只是从web复制/粘贴,上面的答案可能会被pycharm错误地解析。要修复,请尝试将两个字符串合并到一行中:
型
我发现这个修复了V12.0.0的问题
u7up0aaq6#
您可以使用yt-dlp:https://github.com/yt-dlp/yt-dlp
字符串
然后,对于您的视频(mp4 + 1080 p),使用以下代码:
型
bfhwhh0e7#
升级pytube
python3 -m pip install --升级pytube
9wbgstp78#
谢谢,这解决了error - pytube现在给出了各种其他错误,并通过在错误发生的行添加以下内容为我解决了它:
在417线附近。。
字符串
344号线附近
型
第321章把它改成:
型
在这之后,它开始为我工作。