pytube:AttributeError:“NoneType”对象没有属性“span”cipher.py

Moh*_*san 4 python youtube youtube-dl pytube

昨天这工作正常,今天我在我的本地计算机、colab 笔记本、甚至在我的 VPS 上遇到错误。

/usr/local/lib/python3.9/dist-packages/pytube/cipher.py in get_throttling_plan(js)
    409     match = plan_regex.search(raw_code)
    410 
--> 411     transform_plan_raw = find_object_from_startpoint(raw_code, match.span()[1] - 1)
    412 
    413     # Steps are either c[x](c[y]) or c[x](c[y],c[z])
Run Code Online (Sandbox Code Playgroud)

from pytube import YouTube def audio_download(video_url): audio_file = YouTube(video_url).streams.filter(only_audio=True).first().download(filename="audio.mp4") return 'ok'

预计下载音频。我什至尝试按照其他解决方案中所述更改 cipher.py 文件,但不起作用。

s4c*_*4ch 7

找到了解决方案。cipher.py 第 411 行

transform_plan_raw = find_object_from_startpoint(raw_code, match.span()[1] - 1)
Run Code Online (Sandbox Code Playgroud)

transform_plan_raw = js
Run Code Online (Sandbox Code Playgroud)