gphoto_service = googleapiclient.discovery.build(
'photoslibrary', 'v1', credentials=creds, static_discovery=False)
all_photos = gphoto_service.mediaItems().list().execute()
all_photos = all_photos['mediaItems']
len(all_photos)
output:
25
Follow the code above, I can handle only first 25 of all photos in my Google photo. In fact, there are thousands of photos. I guess it take a 'chunk' of items at a time to save memory.
But how can I get 'next chunk' of photos?
gphoto_service = googleapiclient.discovery.build(
'photoslibrary', 'v1', credentials=creds,
static_discovery=False)
# get first page (25 photos)
page_photos = gphoto_service.mediaItems().list().execute()
nextPageToken = page_photos['nextPageToken']
# get next page
page_photos = gphoto_service.mediaItems().list(
pageSize=25, pageToken=nextPageToken).execute()
nextPageToken = page_photos['nextPageToken']