Progressing on gcal

This commit is contained in:
2026-05-27 02:02:53 +00:00
parent 91410d41b4
commit c44c127ccf
2 changed files with 39 additions and 25 deletions

View File

@@ -36,15 +36,29 @@ def main():
try:
service = build("calendar", "v3", credentials=creds)
calendars_to_use = [\
# "meneelyl@gmail.com",\
"Family",\
# "Tim Meneely2",\
# "meneelyt@gmail.com",\
"1532 Ingomar Heights Road",\
"Vivienne",\
"Benjamin",\
"Madeline"\
]
calendarids = []
calendarsummaries = []
calendar_list = (service.calendarList().list()).execute().get("items", [])
for result in calendar_list:
calendarids.append(result.get("id",[]))
calendarsummaries.append(result.get("summary",[]))
if result.get("summary",[]) in calendars_to_use:
calendarids.append(result.get("id",[]))
calendarsummaries.append(result.get("summary",[]))
#print("result",result.get("summary",[]),result.get("id",[]))
#print("summaries",calendarsummaries)
print("summaries",calendarsummaries)
#print("first result",calendar_list[0])
#print("first result",calendar_list[len(calendar_list)-1])
#result meneelyl@gmail.com meneelyl@gmail.com
@@ -62,29 +76,29 @@ def main():
# Call the Calendar API
now = datetime.datetime.now(tz=datetime.timezone.utc).isoformat()
print("Getting the upcoming 10 events")
for i in len(calendarids)-1:
print("Calendar: ",i,calendarsummaries[i])
events_result = (
service.events()
.list(
calendarId="family14345103599446093558@group.calendar.google.com", #"meneelyt@gmail.com", #"ed47cdac4f626432af8c0d1956499d258d0365cf3fe6ee70ce73d7d478b0f1dd@group.calendar.google.com", #"primary",
timeMin=now,
maxResults=3,
singleEvents=True,
orderBy="startTime",
for i in range(0,len(calendarids)):
#print("Calendar: ",i,calendarsummaries[i])
events_result = (
service.events()
.list(
calendarId=calendarids[i], #"family14345103599446093558@group.calendar.google.com", #"meneelyt@gmail.com", #"ed47cdac4f626432af8c0d1956499d258d0365cf3fe6ee70ce73d7d478b0f1dd@group.calendar.google.com", #"primary",
timeMin=now,
maxResults=10,
singleEvents=True,
orderBy="startTime",
)
.execute()
)
.execute()
)
events = events_result.get("items", [])
events = events_result.get("items", [])
if not events:
print("No upcoming events found.")
return
if not events:
print("No upcoming events found.")
return
# Prints the start and name of the next 10 events
for event in events:
start = event["start"].get("dateTime", event["start"].get("date"))
print(start, event["summary"])
# Prints the start and name of the next 10 events
for event in events:
start = event["start"].get("dateTime", event["start"].get("date"))
print(start, event["summary"],"(from "+calendarsummaries[i]+")")
except HttpError as error:
print(f"An error occurred: {error}")