-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_event.py
36 lines (30 loc) · 1.4 KB
/
list_event.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from cal_setup import get_calendar_service
def get_list_event(eventnumber,tmin,tmax):
service = get_calendar_service()
# Call the Calendar API
events_result = service.events().list(calendarId='primary',
timeMin=tmin,
timeMax=tmax,
maxResults=eventnumber,
singleEvents=True,
orderBy='startTime').execute()
events = events_result.get('items', [])
print(events)
dictlist = []
if not events:
print('No upcoming events found.')
print(f'Getting List of {len(events)} events')
for event in events:
end = event['end'].get('dateTime', event['end'].get('date'))
#end_time = datetime.strftime(dtparse(end), format=tmfmt)
start = event['start'].get('dateTime', event['start'].get('date'))
#start_time = datetime.strftime(dtparse(start), format=tmfmt)
event_title_summary = event['summary']
event_description = event['description']
html_link = event['htmlLink']
dictlist.append({'start_datetime': start,
'end_datetime':end,
'eventtitle' : event_title_summary,
'html_link' : html_link,
'event_desc': event_description})
return(dictlist)