Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

YouTube API to extract data from large amount of video IDs

$
0
0

I have a list of 2055 different video IDs (video_ids). I am trying to pull details (likes, views, etc.) from each of these videos and add them to a dictionary.

all_video_data = []request = youtube.videos().list(        part="snippet,contentDetails,statistics",        id=video_ids    )response = request.execute()for video in response['items']:    data_keep = {'snippet': ['channelTitle', 'title', 'publishedAt'],'statistics': ['viewCount', 'likeCount', 'commentCount'],'contentDetails': ['duration']                }    video_data = {}    video_data['video_id'] = video['id']    for k in data_keep.keys():        for v in data_keep[k]:            video_data[v] = video[k][v]    all_video_data.append(video_data)

The error I'm getting is because of my request block. The limit of videos per request is 50, so it makes sense when I try to do 2055. Should I be looping a request for each video id? Should I loop a request for each 50 IDs?

Tried smaller data sets of less than 50, worked. Not sure how to loop a request for every 50 and append.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>