python pytube 错误'NoneType' 对象没有属性'span'
python pytube Error 'NoneType' object has no attribute 'span'
我昨天在使用 pytube,它没有任何问题。但是今天突然停止了,我在尝试获取视频流时遇到了这个错误。我尝试用不同的版本卸载并重新安装它,但没有任何改变。
如何解决?
Traceback (most recent call last): File "<stdin>", line 1, in
<module File
"C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py",
line 292, in streams
return StreamQuery(self.fmt_streams) File "C:\Users21\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:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py",
line 409, in apply_signature
cipher = Cipher(js=js) File "C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py",
line 44, in __init__
self.throttling_array = get_throttling_function_array(js) File "C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py",
line 323, in get_throttling_function_array
str_array = throttling_array_split(array_raw) File "C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\parser.py",
line 158, in throttling_array_split
match_start, match_end = match.span() AttributeError: 'NoneType' object has no attribute 'span'
pytube/pytube/parser.py
f06e071
中的第 152
行
func_regex = re.compile(r"function\([^)]+\)")
应该改为
func_regex = re.compile(r"function\([^)]*\)")
编辑:
将 +
更改为 *
我昨天在使用 pytube,它没有任何问题。但是今天突然停止了,我在尝试获取视频流时遇到了这个错误。我尝试用不同的版本卸载并重新安装它,但没有任何改变。
如何解决?
Traceback (most recent call last): File "<stdin>", line 1, in
<module File
"C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py",
line 292, in streams
return StreamQuery(self.fmt_streams) File "C:\Users21\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:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py",
line 409, in apply_signature
cipher = Cipher(js=js) File "C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py",
line 44, in __init__
self.throttling_array = get_throttling_function_array(js) File "C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\cipher.py",
line 323, in get_throttling_function_array
str_array = throttling_array_split(array_raw) File "C:\Users21\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\parser.py",
line 158, in throttling_array_split
match_start, match_end = match.span() AttributeError: 'NoneType' object has no attribute 'span'
pytube/pytube/parser.py
f06e071
152
行
func_regex = re.compile(r"function\([^)]+\)")
应该改为
func_regex = re.compile(r"function\([^)]*\)")
编辑:
将 +
更改为 *