Open In App

Pafy – Getting Playlist

Last Updated : 02 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can get the youtube playlist in pafy. Pafy is a python library to download YouTube content and retrieve metadata. Pafy object is the object which contains all the information about the given video. A playlist in YouTube is a list, or group, of videos that plays in order, one video after the other. When one video finishes playing, the next starts automatically so you don’t have to click or search to start playing a new video. The playlist url should exist on youtube as it get the information of those videos which are present on the youtube. YouTube is an American online video-sharing platform. In order to do this we use pafy.get_playlist method

Syntax : pafy.get_playlist(url) 

Argument : It takes url of playlist as argument 

Return : It returns dictionary

Below is the implementation 

Python3




# importing pafy
import pafy
   
# url of playlist
url = "https://www.youtube.com / playlist?list = PLqM7alHXFySGqCvcwfqqMrteqWukz9ZoE"
 
# getting playlist
playlist = pafy.get_playlist(url)
 
# printing playlist
print(playlist["title"])


Output :

Amazon Programming Interview Questions | GeeksforGeeks

Another example 

Python3




# importing pafy
import pafy
   
# url of playlist
url = "https://www.youtube.com / playlist?list = PLqM7alHXFySE71A2bQdYp37vYr0aReknt"
   
# getting playlist
playlist = pafy.get_playlist(url)
 
# printing playlist
print(playlist["title"])


Output :

Google Programming Interview Questions4

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads