Python 3 Script to Get Youtube Channel Title,Views,Subscribers,Videos and Playlist Information Using Youtube Data API V3 Full Project For Beginners

 

 

In order to get started you need to be having a google account and after that you need to have a google developer console account and then enable the youtube data api and then get the api_key

 

 

# Import Module
from googleapiclient.discovery import build

# Create YouTube Object
youtube = build('youtube', 'v3',
                developerKey='Enter API key')

ch_request = youtube.channels().list(
    part='statistics',
    id='Enter Channel ID')

# Channel Information
ch_response = ch_request.execute()

sub = ch_response['items'][0]['statistics']['subscriberCount']
vid = ch_response['items'][0]['statistics']['videoCount']
views = ch_response['items'][0]['statistics']['viewCount']

print("Total Subscriber:- ", sub)
print("Total Number of Videos:- ", vid)
print("Total Views:- ", views)

 

 

 

# Import Module
from googleapiclient.discovery import build


def playlist_video_links(playlistId):

    nextPageToken = None
    
    # Creating youtube resource object
    youtube = build('youtube', 'v3',
                    developerKey='Enter API Key')

    while True:

        # Retrieve youtube video results
        pl_request = youtube.playlistItems().list(
            part='snippet',
            playlistId=playlistId,
            maxResults=50,
            pageToken=nextPageToken
        )
        pl_response = pl_request.execute()

        # Iterate through all response and get video desription
        for item in pl_response['items']:

            description = item['snippet']['description']

            print(description)

            print("\n")

        nextPageToken = pl_response.get('nextPageToken')

        if not nextPageToken:
            break


playlist_video_links('Enter Playlist ID')

 

See also  Python 3 invoicegenerator Library Script to Generate Billing Invoice PDF Document Full Project For Beginners

 

# 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"))

Leave a Reply