首页 > 解决方案 > 无法在 Python 3 中使用 pytube 从 YouTube 下载视频

问题描述

from pytube import YouTube
yt = YouTube("https://www.youtube.com/watch?v=9bZkp7q19f0")
yt = yt.streams.first()
yt.download('Downloads')

我正在使用 pytube 从 YouTube 下载视频,但它引发了以下错误

Traceback (most recent call last):
  File "E:/Python/landchecks/download_video", line 2, in <module>
    yt = YouTube("https://www.youtube.com/watch?v=9bZkp7q19f0")
  File "E:\Python\landchecks\venv\lib\site-packages\pytube\__main__.py", line 88, in __init__
    self.prefetch_init()
  File "E:\Python\landchecks\venv\lib\site-packages\pytube\__main__.py", line 97, in prefetch_init
    self.init()
  File "E:\Python\landchecks\venv\lib\site-packages\pytube\__main__.py", line 143, in init
    mixins.apply_descrambler(self.player_config_args, fmt)
  File "E:\Python\landchecks\venv\lib\site-packages\pytube\mixins.py", line 96, in apply_descrambler
    for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'

标签: pythonpython-3.xpytube

解决方案


推荐阅读