使用pytube获取YouTube播放列表视频详细信息时遇到错误
使用pytube获取YouTube播放列表视频详细信息时遇到错误
我尝试用pytube获取播放列表中每个视频的详细信息,官方文档里只说明了如何从播放列表下载视频,但没讲怎么获取视频信息。
因为每个视频都是YouTube对象,文档里提到可以用yt_video.title这类方式获取属性,所以我写了这段代码:
from pytube import Playlist playlist = Playlist('https://www.youtube.com/playlist?list=PLS1QulWo1RIaJECMeUT4LFwJ-ghgoSH6n') for video in playlist.videos: print(video.title)
但这段代码运行失败了,我遇到了如下错误:
Traceback (most recent call last): File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 341, in title self._title = self.vid_info['videoDetails']['title'] KeyError: 'videoDetails' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\****\Desktop\dev\api\yt.py", line 15, in <module> print(video.title) File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\site-packages\pytube\__main__.py", line 346, in title raise exceptions.PytubeError( pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=41qgdwd3zAg. Please file a bug report at https://github.com/pytube/pytube
我想知道自己哪里操作有误,或者正确获取播放列表视频详细信息的方法是什么?
备注:内容来源于stack exchange,提问作者TCombu
相关产品推荐
相关产品推荐

