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

How to extract metadata for more than 20000 videos from channel using YouTube Data API v3?

$
0
0

I want to use Youtube Data API v3 to extract video metadata (especially title and publish date) for all videos in a channel. Currently, I'm only being able to extract details the last 20000 videos using the playlistItems() endpoint. Is there a way to extract metadata for more than 20000 videos from a single channel?

Here's the python code I'm using to extract metadata for 20000 videos.

youtube = build('youtube','v3',developerKey= "YOUTUBE_API_KEY")channelId = "CHANNEL_ID"# getting all video detailscontentdata = youtube.channels().list(id=channelId,part='contentDetails').execute()playlist_id = contentdata['items'][0]['contentDetails']['relatedPlaylists']['uploads']videos = [ ]next_page_token = Nonewhile 1:    res = youtube.playlistItems().list(playlistId=playlist_id,part='snippet',maxResults=50,pageToken=next_page_token).execute()    videos += res['items']    next_page_token = res.get('nextPageToken')    if next_page_token is None:        break# getting video id for each videovideo_ids = list(map(lambda x:x['snippet']['resourceId']['videoId'], videos))

The solution to this problem can either be forcing the API to extract metadata more than 20000 videos from a channel or specifying a time period during which video was uploaded. That way, the code can be run again and again for multiple time periods to extract metadata for all videos.


Viewing all articles
Browse latest Browse all 3641

Trending Articles



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