To automate adding events to your Google Calendar, use the GoogleCalendar class to manage the connection and the Event class to define individual calendar entries. You can iterate through a range of dates (using libraries like beautiful_date) and call gc.add_event(e) for each event you wish to create.
This example demonstrates how to schedule a series of daily push-up goals starting from the next Monday.
from gcsa.google_calendar import GoogleCalendar
from gcsa.event import Event
from beautiful_date import D, drange, days, MO
gc = GoogleCalendar()
PUSH_UPS_COUNT = [
5, 5, 0, 5, 10, 0, 10,
0, 12, 12, 0, 15, 15, 0,
20, 24, 0, 25, 30, 0, 32,
35, 35, 0, 38, 40, 0, 42,
45, 50
]
# starting next Monday (of course)
# +1 days for the case that today is Monday
start = D.today()[9:00] + 1 * days + MO
end = start + len(PUSH_UPS_COUNT) * days
for day, push_ups in zip(drange(start, end), PUSH_UPS_COUNT):
e = Event(
f'{push_ups} Push-Ups' if push_ups else 'Rest',
start=day,
minutes_before_popup_reminder=5
)
gc.add_event(e)