python中的pytube.exceptions.RegexMatchError

2024-06-28 11:22:02 发布

您现在位置: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”重新安装pytube+https://github.com/nficano/pytube.git“以及”pip安装pytube”。但错误仍然存在


Tags: inpyhomegetvenvlibpackagesline
1条回答
网友
1楼 · 发布于 2024-06-28 11:22:02

您可以安装:

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_函数中\u name(js:str)->;str:函数

相关问题 更多 >