Pafy – Checking CC for Each Item of Playlist
In this article we will see how we can check if the item of playlist is CC 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. Metadata is “data that provides information about other data”. CC stands for Closed Caption, it’s there just to toggle between subtitles, If you turn it on the subtitles(closed captions to be more precise) either submitted by the author of the video or generated by speech recognition starts displaying along with the video.
We can get the playlist from youtube in pafy with the help of
get_playlist method, below is the command given to do this
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 to get the playlist ID
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
6. Use ‘is_cc’ as keyword with the meta data and store the result and print it
Below is the implementation
Please Login to comment...