Getting the title of youtube video in pytube3?

Viewed 5666

I am trying to build an app to download YouTube videos in python using pytube3.
But I am unable to retrieve the title of the video.
Here goes my code:

from pytube import YouTube
yt = YouTube(link)
print(yt.title)

No matter whatever is the link I always get the title returned as YouTube instead of title of the video. Is there anyway to fix it?

4 Answers

try this instead

yt.streams[0].title

or

yt.streams[0].default_filename

pytube3 is no longer being maintained and so this bug will probably not be fixed on this library. pytubex is a version of pytube that is still being maintained and has fixed this and many other bugs.

try: yt.title

output: Rick Astley - Never Gonna Give You Up (Video)

(or the video name of the link you entered and no its not a rickroll, I was listening to this while scrolling through StackOverFlow).

Try: print(yt._title) It works for me.

Related