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

YouTube Playlist API does not return all videos in a channel

$
0
0

We are trying to get all videos in a channel, like this. This list has 291k videos, we figured out the channel id of this channel (and replaced the second alphabet "C" in the id by "U"), and trying this code, iterating over 50 videos at a time. We are getting only upto some 20k videos, not more than that. Any idea on how to fix this and get all 291k videos in this channel? Checked this for a variety of channels with large number of videos, all have the same problem.

api_key = "my Google YouTube API V3 key"from googleapiclient.discovery import buildyoutube = build('youtube', 'v3', developerKey=api_key)def get_channel_videos():        videos = []    next_page_token = None    while 1:        res = youtube.playlistItems().list(playlistId="UU...",                                            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    return videosvideos = get_channel_videos()with open("video.txt", "a") as myfile:    for video in videos:        myfile.write(f"{video['snippet']['resourceId']['videoId']} => {video['snippet']['title']}\n")print(f"Total video count => {len(videos)}")

Viewing all articles
Browse latest Browse all 3638

Trending Articles



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