pytube.exceptions.RegexMatchError 在 python
pytube.exceptions.RegexMatchError in python
我可以尝试查找不同格式的 YouTube 视频。使用 pytube 流过滤器但出现错误 pytube.exceptions.RegexMatchError.
from pytube import YouTube
url = input('Enter url :')
link = YouTube(url)
print(link.title)
obj = link.streams.filter(progressive="True")
print(obj)
出现此错误:
Traceback (most recent call last):
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 170, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 279, in get_throttling_function_name
caller="get_throttling_function_name", pattern="multiple"
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 "main.py", line 44, in <module>
yt = myVideo.streams.filter(type='mp4')
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 285, in streams
return StreamQuery(self.fmt_streams)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 279, in get_throttling_function_name
caller="get_throttling_function_name", pattern="multiple"
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
我也可以使用“pip install git+https://github.com/nficano/pytube.git[=22 重新安装 pytube =]”和“pip install pytube”。但错误仍然存在。
您可以安装:
pip install pytube==11.0.1 or pip install --upgrade pytube
或者您可以在 pytube/cipher.py 中更改:
edit line:r'a\.[A-Z]&&\(b=a\.[sg]et\("n"\)\)&&\(b=([^(]+)\(b\),a\.[sg]et\("n",b\)\)}};'
到
r'a\.C&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\),a\.set\("n",b\)\)}};',
在 def get_throttling_function_name(js: str) -> str: 函数中。
我可以尝试查找不同格式的 YouTube 视频。使用 pytube 流过滤器但出现错误 pytube.exceptions.RegexMatchError.
from pytube import YouTube
url = input('Enter url :')
link = YouTube(url)
print(link.title)
obj = link.streams.filter(progressive="True")
print(obj)
出现此错误:
Traceback (most recent call last):
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 170, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 279, in get_throttling_function_name
caller="get_throttling_function_name", pattern="multiple"
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 "main.py", line 44, in <module>
yt = myVideo.streams.filter(type='mp4')
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 285, in streams
return StreamQuery(self.fmt_streams)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/__main__.py", line 177, in fmt_streams
extract.apply_signature(stream_manifest, self.vid_info, self.js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/extract.py", line 409, in apply_signature
cipher = Cipher(js=js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 43, in __init__
self.throttling_plan = get_throttling_plan(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 387, in get_throttling_plan
raw_code = get_throttling_function_code(js)
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 293, in get_throttling_function_code
name = re.escape(get_throttling_function_name(js))
File "/home/jay/PycharmProjects/videoinfo/venv/lib/python3.7/site-packages/pytube/cipher.py", line 279, in get_throttling_function_name
caller="get_throttling_function_name", pattern="multiple"
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
我也可以使用“pip install git+https://github.com/nficano/pytube.git[=22 重新安装 pytube =]”和“pip install pytube”。但错误仍然存在。
您可以安装:
pip install pytube==11.0.1 or pip install --upgrade pytube
或者您可以在 pytube/cipher.py 中更改:
edit line:r'a\.[A-Z]&&\(b=a\.[sg]et\("n"\)\)&&\(b=([^(]+)\(b\),a\.[sg]et\("n",b\)\)}};'
到
r'a\.C&&\(b=a\.get\("n"\)\)&&\(b=([^(]+)\(b\),a\.set\("n",b\)\)}};',
在 def get_throttling_function_name(js: str) -> str: 函数中。