python - Pytube 错误。AttributeError:“NoneType”对象没有属性“下载”
问题描述
嗨,我正在开发一个 python youtube 下载器,这是一项非常简单的任务。我用了 pytube 一段时间,从来没有遇到过这个错误。我的代码如下:
from pytube import YouTube
import pytube
yt_title = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI').title
ytd = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI').streams.first().download()
我得到的错误消息是:
Traceback (most recent call last):
File ".\test.py", line 5, in <module>
ytd = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI').streams.first().download()
AttributeError: 'NoneType' object has no attribute 'download'
这些是电子规格:
Name: pytube
Version: 10.0.0
Summary: Python 3 library for downloading YouTube Videos.
Home-page: https://github.com/nficano/pytube
Author: Nick Ficano, Harold Martin
Author-email: nficano@gmail.com, harold.martin@gmail.com
License: MIT
Location: 'location of the package'
Requires: typing-extensions
Required-by:
我使用的视频是: https ://www.youtube.com/watch?v=ZjDZrReZ4EI
我意识到,一些我在几个小时前能够下载的视频现在无法下载
我刚刚卸载了 pytube 并安装了 pytube3。但现在我收到以下错误:
pytube.exceptions.RegexMatchError: get_ytplayer_config: could not find match
for config_patterns
它不允许我下载任何视频。
解决方案
您必须卸载pytube并使用 pip安装pytube3 。如果它不起作用,则打印流并查看您是否正在获取流
yt = YouTube('https://www.youtube.com/watch?v=ZjDZrReZ4EI')
print(yt.streams)
推荐阅读
- python - Python函数SOS
- vb6 - mscomctl.ocx 未找到 VB6
- android - 当有多种图像类型时,将图像从 Firestore 加载到 RecyclerView
- java - 如何最好地避免 java bean 的通配符
- javascript - 将javascript递归异步方法写入对象
- sqlite - 避免 .mode html 中的 html 实体
- extjs - 没有 x-innerhtml 的 Extjs 小部件/组件
- sql - 跨不同表的不同用户详细信息
- c++ - 默认新对齐
- outlook - 使用未经用户身份验证的 Microsoft Graph 和 Daemon 应用程序同步 Microsoft 日历