admin管理员组文章数量:1245900
from pytube import YouTube
link = input("Enter the video link here ->")
y_tube = YouTube(link)
print(y_tube.title)
Output:
Enter the video link here ->
Traceback (most recent call last):
File "C:\Users\kumar_0nqo0ht\AppData\Local\Programs\Python\Python311\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:\Projects\videodownloader\main.py", line 8, in <module>
print(f'y_tube.Title->{y_tube.title}')
^^^^^^^^^^^^
File "C:\Users\kumar_0nqo0ht\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\__main__.py", line 346, in title
raise exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of . Please file a bug report at
from pytube import YouTube
link = input("Enter the video link here ->")
y_tube = YouTube(link)
print(y_tube.title)
Output:
Enter the video link here ->https://youtu.be/rkR4sFODnIM?si=FqDP5s3TEDCMStqz
Traceback (most recent call last):
File "C:\Users\kumar_0nqo0ht\AppData\Local\Programs\Python\Python311\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:\Projects\videodownloader\main.py", line 8, in <module>
print(f'y_tube.Title->{y_tube.title}')
^^^^^^^^^^^^
File "C:\Users\kumar_0nqo0ht\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytube\__main__.py", line 346, in title
raise exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of https://youtube/watch?v=rkR4sFODnIM. Please file a bug report at https://github/pytube/pytube
Share
Improve this question
edited Feb 15 at 11:52
quamrana
39.4k13 gold badges55 silver badges76 bronze badges
asked Feb 15 at 11:38
Anushka kumariAnushka kumari
1
1
- pytube has not been updated since May 2023 so it's unlikely to still function as anything dealing with YouTube is sensitive to any changes YouTube does behind the scenes (and they quite often do change things). Trying another library is your best bet, such as yt-dlp like sjalu suggested – Oliver Henriksson Commented Feb 15 at 14:09
1 Answer
Reset to default 1You can use yt_dlp
library instead. Something like this:
def get_youtube_title(url):
ydl_opts = {"quiet": True}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url, download=False)
return info.get('title', 'Title not found')
Hope it works!
本文标签: pythoni don39t get video title using pytubeStack Overflow
版权声明:本文标题:python - i don't get video title using pytube - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740240678a2247295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论