def fetch_events(): username = '******' visibility = 'private-fa3dc4aa8a14f7da0099eb6fb34a036a' query = CalendarEventQuery(username, visibility) query.sortorder = 'a' query.futureevents = 'true' query.orderby = 'starttime' calendar_service = CalendarService() feed = calendar_service.CalendarQuery(query) return [{'title':item.title.text, 'start_time':parse(item.when[0].start_time), 'end_time':parse(item.when[0].end_time), 'location':item.where[0].value_string} for item in feed.entry]
def upcoming_events(days=90): # Create a Google Calendar client to talk to the Google Calendar service. calendar_client = CalendarService() # Set up a query with the GCAL_ID. query = CalendarEventQuery(app.config['GCAL_ID'], 'public', 'full') query.orderby = 'starttime' query.sortorder = 'descending' # we're interested in events in the next 60 days if we wanted all the # futuer events, we'd use query.futureevents='true' and ignore the # start_min, start_max options month_offset = timedelta(days=days) start_min = _now() start_max = start_min + month_offset query.start_min = start_min.isoformat() query.start_max = start_max.isoformat() # query gcal for the time interval return list(reversed([CalendarEvent(e) for e in calendar_client.CalendarQuery(query).entry]))