Search code examples
pythonpython-3.xpytube

How to get youtube video description with pytube


When I try to get youtube video description with this code:

from pytube import YouTube
video = YouTube("https://www.youtube.com/watch?v=N9bLO0XY3zs&ab_channel=CompanyEggs")
print (video.description())

I get

Traceback (most recent call last):
  File "C:/Users/mmthe/PycharmProjects/pythonProject1/main.py", line 24, in <module>
    print (video.description())
TypeError: 'str' object is not callable

How can I fix this?


Solution

  • Pytube gives you an object and you just need to print / access attributes of that object.

    from pytube import YouTube
    
    video = YouTube("https://www.youtube.com/watch?v=N9bLO0XY3zs&ab_channel=CompanyEggs")
    print (video.description)
    

    gives

    Just drink another one
    
    
    Song: https://www.youtube.com/watch?v=Ag1o3koTLWM