pytube.exceptions.RegexMatchError: get_throttling_function_name: 找不到多个匹配项

我曾经通过以下方式下载歌曲:

from pytube import YouTube
video = YouTube('https://www.youtube.com/watch?v=AWXvSBHB210')
video.streams.get_by_itag(251).download()

从今天开始出现这个错误:

回溯(最近一次调用):文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube_ main _.py”,第 170 行,在 fmt_streams extract.apply_signature(stream_manifest , self.vid_info, self.js) 文件 "C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py", line 409, in apply_signature cipher = Cipher( js=js) 文件 "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) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py”,第 387 行,在 get_throttling_plan raw_code = get_throttling_function_code(js ) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py”,第 293 行,get_throttling_function_code name = re.escape(get_throttling_function_name(js)) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py”,第 278 行,在 get_throttling_function_name 中引发 RegexMatchError( pytube.exceptions.RegexMatchError: get_throttling_function_name: 找不到匹配多个

在处理上述异常的过程中,又发生了一个异常:

回溯(最近一次通话):文件“C:\Users\Me\Documents\YouTubeDownloader.py”,第 3 行,在 video.streams.get_by_itag(251).download() 文件“C:\Users\Me\AppData \Local\Programs\Python\Python39\lib\site-packages\pytube_ main _.py”,第 285 行,在流中返回 StreamQuery(self.fmt_streams) 文件“C:\Users\Me\AppData\Local\Programs\Python \Python39\lib\site-packages\pytube_ main _.py”,第 177 行,在 fmt_streams extract.apply_signature(stream_manifest, self.vid_info, self.js) 文件“C:\Users\Me\AppData\Local\Programs\ Python\Python39\lib\site-packages\pytube\extract.py”,第 409 行,在 apply_signature cipher = Cipher(js=js) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib \site-packages\pytube\cipher.py”,第 43 行,在init 中
self.throttling_plan = get_throttling_plan(js) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py”,第 387 行,在 get_throttling_plan raw_code = get_throttling_function_code(js ) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py”,第 293 行,get_throttling_function_code name = re.escape(get_throttling_function_name(js)) 文件“C:\Users\Me\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py”,第 278 行,在 get_throttling_function_name 中引发 RegexMatchError( pytube.exceptions.RegexMatchError: get_throttling_function_name: 找不到匹配多个

回答

我在使用 pytube 11.0.0 时遇到了同样的问题

所以发现在 cipher.py 类中的 pytube 库中存在正则表达式过滤器不匹配

function_patterns = [

    r'a\.C&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\),a\.set\("n",b\)\)}};',
]

现在昨天更新了pytube代码到11.0.1

function_patterns = [

    r'a\.[A-Z]&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\)',
]

通过此代码更新,现在可以使用 pytube 下载 youtube 视频了!!!

使用此命令更新您的 pytube 库

python3 -m pip install --upgrade pytube


以上是pytube.exceptions.RegexMatchError: get_throttling_function_name: 找不到多个匹配项的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>