提问人:Faust 提问时间:9/6/2023 更新时间:9/6/2023 访问量:58
无法在 Python 中使用 pytube 打印视频标题
cant print the video title using pytube in python
问:
我在使用从 pytube 获取视频标题时遇到了问题。似乎 pytube 在获取视频标题时遇到问题,或者 pytube 似乎无法获取它。我在使用补丁时已将 pytube 更新到 15.0.0 版。
因此,我在使用 PyTube 使用 URL 链接获取视频的视频标题时遇到了问题,任何解决此问题的线索。
from pytube import YouTube
print("input url below:")
input_url = input()
my_video = YouTube(input_url)
if input_url == "":
pass
else:
print(my_video.title)
print(my_video.thumbnail_url)
my_video = my_video.streams.get_lowest_resolution
print(my_video)
这是错误
Traceback (most recent call last):
File "C:\Users\(censored)\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pytube\__main__.py", line 330, 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\(censored)\Desktop\youtube video downloader\main.py", line 9, in <module>
print(my_video.title)
^^^^^^^^^^^^^^
File "C:\Users\(censored)\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pytube\__main__.py", line 335, in title
raise exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=vEQ8CXFWLZU. Please file a bug report at https://github.com/pytube/pytube
答:
评论
my_video.title
self.vid_info['videoDetails']