Newbie coder here, wanting to code for research purposes. I used Jupyter, Python 3
playlist_id = 'UUYk4LJI0Pr6RBDWowMm-KUw'and then
def get_video_ids (youtube, playlist_id): request = youtube.playlistItems().list( part='contentDetails', playlistId = playlist_id, maxResults = 50) response = request.execute() video_ids = [] for i in range (len(response['items'])): video_ids.append(response['items'][i]['contentDetails']['videoId']) next_page_token = response.get('nextPageToken') more_pages = True while more_pages: if next_page_token is None: more_pages = False else: request = youtube.playlistItems().list( part='contentDetails', playlistId = playlist_id, maxResults = 50, pageToken = next_page_token) response = request.execute() for i in range (len(response['items'])): video_ids.append(response['items'][i]['contentDetails']['videoId']) next_page_token = response.get('nextPageToken') return video_idsto get a long list of video ids
video_ids = get_video_ids (youtube, playlist_id)def get_video_details (youtube, video_ids): all_video_stats = [] for i in range(0, len(video_ids), 50): request = youtube.videos().list( part='snippet,statistics', id=','.join(video_ids[i:i+50])) response = request.execute() for video in response ['items']: video_stats = dict( Title = video['snippet']['title'], Publish_date = video['snippet']['publishedAt'], View_Count = video['statistics']['viewCount'] #Comment_Count = video['statistics']['commentCount'] ) all_video_stats.append(video_stats) return all_video_statswhen i tried to use get_video_details (youtube, video_ids)
It only shows 24 data, instead of all hundreds of videos in it.Help?
Was expecting to get hundreds of data with the use of len() function.