Count Number of Playlist of YouTube Channel
In this section, we will write a Python Script which will count the number of a playlist of YouTube channels using YouTube API.
Approach:
- Here we will use build(), playlists(), list(), execute() methods it will give YouTube channel details.
- Inside list method, pass contentDetails and snippet in part property and in channelId property pass channelId.
Below is the Implementation:
Python3
# Import Module from googleapiclient.discovery import build # Create YouTube Object youtube = build( 'youtube' , 'v3' , developerKey = 'Enter API key' ) # Get video count def Channel_Depth_details(channel_id): pl_request = youtube.playlists(). list ( part = 'contentDetails,snippet' , channelId = 'channel_id' , maxResults = 50 ) pl_response = pl_request.execute() return len (pl_response[ 'items' ]) print (Channel_Depth_details( "Channel ID" )) |
Output:
Get information about YouTube Channel using Python
Prerequisite: YouTube API
Google provides a large set of APIs for the developer to choose from. Each and every service provided by Google has an associated API. Being one of them, YouTube Data API is very simple to use provides features like –
- Search for videos
- Handle videos like retrieve information about a video, insert a video, delete a video, etc.
- Handle Subscriptions like lists all the subscriptions, insert or delete a subscription.
- Retrieve information about comments like replies to a specific comment identified by a parentId etc.
In this article, we are going to perform various YouTube operations in Python using the YouTube API.
Contact Us