How can i printing all the video names in playlist with Python?

Viewed 93

I want to make a program that prints all the video names in a Playlist but i get " 'str' object is not callable" error on line 10. How can i fix it, thanks!

from pytube import YouTube
from pytube import Playlist

p = Playlist("https://www.youtube.com/watch?v=p6IIWuwdNIc&list=PL3-sRm8xAzY-556lOpSGH6wVzyofoGpzU")
for url in p.video_urls[:10]:
    videourl = url

yt = YouTube(videourl)  
videonames = yt.title()

print(videonames)
1 Answers

Use title rather than title():

from pytube import YouTube
from pytube import Playlist

playlist = Playlist("https://www.youtube.com/watch?v=p6IIWuwdNIc&list=PL3-sRm8xAzY-556lOpSGH6wVzyofoGpzU")

# Print first 10 video names in playlist
for url in playlist.video_urls[:10]:
    yt = YouTube(url)
    video_name = yt.title
    print(video_name)

Output:

DaBaby - Red Light Green Light (Official Video)
Internet Money - His & Hers ft. Don Toliver, Lil Uzi Vert & Gunna (Directed by Cole Bennett)
Wale - Angles (feat. Chris Brown) [Official Music Video]
DDG & OG Parker - Hood Melody ft. YoungBoy Never Broke Again (Official Music Video)
Remble - Touchable (Official Music Video)
Baby Keem, Travis Scott - durag activity (Official Video)
J. Cole - p r i d e . i s . t h e . d e v i l  feat. Lil' Baby (Official Audio)
Isaiah Rashad - Headshots (4r Da Locals) [Official Music Video]
DaBaby - BALL IF I WANT TO (Official Video)
Joyner Lucas - Legend ft. Rick Ross (Official Video)
Related