mirror of
https://github.com/b4tman/sync_ics2gcal
synced 2025-01-21 23:38:58 +00:00
manage_calendars: use nextPageToken for list
By default maximum number of entries returned on one result page is 100
This commit is contained in:
parent
55b67469be
commit
b0a39a1b8c
@ -69,8 +69,16 @@ def load_config():
|
|||||||
|
|
||||||
|
|
||||||
def list_calendars(service):
|
def list_calendars(service):
|
||||||
response = service.calendarList().list(fields='items(id,summary)').execute()
|
calendars = []
|
||||||
for calendar in response.get('items'):
|
page_token = None
|
||||||
|
while True:
|
||||||
|
response = service.calendarList().list(fields='nextPageToken,items(id,summary)', pageToken=page_token).execute()
|
||||||
|
if 'items' in response:
|
||||||
|
calendars.extend(response['items'])
|
||||||
|
page_token = response.get('nextPageToken')
|
||||||
|
if not page_token:
|
||||||
|
break
|
||||||
|
for calendar in calendars:
|
||||||
print('{summary}: {id}'.format_map(calendar))
|
print('{summary}: {id}'.format_map(calendar))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user