【问题标题】:python pytube Error 'NoneType' object has no attribute 'span'python pytube错误'NoneType'对象没有属性'span'
【发布时间】:2022-01-01 08:29:33
【问题描述】:

我昨天在使用 pytube,它运行时没有任何问题。但是今天突然停止了,我在尝试获取视频流时遇到了这个错误。我尝试卸载并使用不同的版本再次安装它,但没有任何变化。

如何解决?

Traceback (most recent call last):   File "<stdin>", line 1, in
<module  File
"C:\Users\2021\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py",
line 292, in streams
    return StreamQuery(self.fmt_streams)   File "C:\Users\2021\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\2021\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\extract.py",
line 409, in apply_signature
    cipher = Cipher(js=js)   File "C:\Users\2021\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:\Users\2021\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:\Users\2021\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'

【问题讨论】:

标签: python youtube pytube


【解决方案1】:

pytube/pytube/parser.py

f06e071 中输入152

func_regex = re.compile(r"function\([^)]+\)")

应该改为

func_regex = re.compile(r"function\([^)]*\)")

编辑:

+ 更改为*

【讨论】:

    猜你喜欢
    • 2021-12-31
    • 2018-05-02
    • 1970-01-01
    • 2014-06-04
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多