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

Python Youtube API not returning all results (nextoken)

$
0
0

im trying to fetch all youtube videos with location near amsterdam airport that were made in 2012 , however im only getting 7 videos in response. I know there is way more youtube videos that were made in 2012 near this locationanybody know why im not getting all the results? Thanks!

# API client libraryimport googleapiclient.discovery# API informationapi_service_name = "youtube"api_version = "v3"DEVELOPER_KEY = ''# API clientyoutube = googleapiclient.discovery.build(        api_service_name, api_version, developerKey = DEVELOPER_KEY)# Notice that nextPageToken now is requested in 'fields' parameterNewPageToken = ""while True:        if NewPageToken == "":                print('request with no token')                request = youtube.search().list(                        part="id,snippet",                        type='video',                        publishedAfter='2012-01-05T11:10:04Z',                        publishedBefore='2012-12-05T11:10:04Z',                        location="52.3076865, 4.767424099999971",                        locationRadius='1km',                        maxResults=1,                        fields="nextPageToken,items(id(videoId),snippet(publishedAt,channelId,channelTitle,title,description))"                )        if NewPageToken != "":                print('request with token')                request = youtube.search().list(                        part="id,snippet",                        type='video',                        publishedAfter='2012-01-05T11:10:04Z',                        publishedBefore='2012-12-31T11:10:04Z',                         location="52.3076865, 4.767424099999971",                        locationRadius='1km',                        maxResults=1,                        fields="nextPageToken,items(id(videoId),snippet(publishedAt,channelId,channelTitle,title,description))",                        pageToken = NewPageToken                )        response = request.execute()        if "nextPageToken" in response:                print('foundToken fetching next data')                NewPageToken = response['nextPageToken']        else:                print('noTokenFound Stopping your script')                break        print(response)        # print(request)

Viewing all articles
Browse latest Browse all 3831

Trending Articles



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