Open In App

Pafy – Getting Keywords for each item of Playlist

Last Updated : 28 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can get keywords of each item of 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. YouTube channel keywords are terms that give YouTube information and context about your channel. Specifically, they help YouTube understand the type of content you produce and who your target audience is. Optimized Channel keywords can also increase the visibility of your channel on YouTube.

We can get the playlist from youtube in pafy with the help of get_playlist method, below is the command given to do this

 pafy.get_playlist(url)

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.

Steps for implementation
1. Import the pafy module
2. Get the playlist with the help of URL of playlist
3. Return play list work as dictionary so use ‘items’ as key with the return playlist
4. Store the result in variable and from the items select the single item
5. With the single item use ‘playlist_meta’ key with it to get the meta data
6. With the meta data use ‘keywords’ key this will return duration for given item

Below is the implementation




# importing pafy
import pafy 
    
# url of playlist
url = "https://www.youtube.com / playlist?list = PLqM7alHXFySGqCvcwfqqMrteqWukz9ZoE"
  
# getting playlist
playlist = pafy.get_playlist(url)
  
# getting playlist items
items = playlist["items"]
  
# selecting single item
item = items[1]
  
# getting pafy object
i_pafy = item['pafy']
      
# getting meta data
metadata = item['playlist_meta']
  
  
# getting keywords of item
value = metadata['keywords']
  
# printing value
print("Keywords :" + str(value))


Output :

Keywords :"

Another example




# importing pafy
import pafy 
    
# url of playlist
url = "https://www.youtube.com / playlist?list = PLqM7alHXFySE71A2bQdYp37vYr0aReknt"
    
# getting playlist
playlist = pafy.get_playlist(url)
  
# getting playlist items
items = playlist["items"]
  
# selecting single item
item = items[2]
  
# getting meta data
metadata = item['playlist_meta']
  
# getting keywords of item
value = metadata['keywords']
  
# printing value
print("Keywords :" + str(value))


Output :

Keywords :GeeksforGeeks Programming Algorithms "Data Structures" Coding Tutorial array "non-negative numbers"


Similar Reads

Pafy - Getting Pafy Object for Each Item of Playlist
In this article we will see how we can get the pafy object from playlist items 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. W
2 min read
Pafy - Getting Watch URL for Each Item of Playlist
In this article we will see how we can get the watch URLfrom playlist items 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. Watc
2 min read
Pafy - Getting Populate of Each Item From Playlist
In this article we will see how we can populate the item to 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. Populate me
2 min read
Pafy - Getting Meta Data for Each Item of Playlist
In this article we will see how we can get the meta data of each item of 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
3 min read
Pafy - Getting Added Date for Each Item in Playlist
In this article we will see how we can get the added date of each item of 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 othe
2 min read
Pafy - Getting User ID for each item of Playlist
In this article we will see how we can get user ID of each item of 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. Each
2 min read
Pafy - Getting Privacy for each item of Playlist
In this article we will see how we can get privacy each item of 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. There a
2 min read
Pafy - Getting Start Value for each item of Playlist
In this article we will see how we can get start value of each item of 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.
2 min read
Pafy - Getting Comment Number for each item of Playlist
In this article we will see how we can get number of comments of each item of 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
2 min read
Pafy - Getting Duration for each item of Playlist
In this article we will see how we can get duration of each item of 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. Dur
2 min read
Article Tags :
Practice Tags :