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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 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) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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') |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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")) |