Skip to content

Instantly share code, notes, and snippets.

@sreeprasad
Last active February 17, 2025 07:09
Show Gist options
  • Save sreeprasad/281ceb487a1df2379c373fd506b1cf87 to your computer and use it in GitHub Desktop.
Save sreeprasad/281ceb487a1df2379c373fd506b1cf87 to your computer and use it in GitHub Desktop.
eb1a luma calendar
import os
import datetime
import google.auth
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]
CREDENTIALS_FILE = "credentials.json"
LUMA_CALENDAR_ID = "[email protected]"
from google_auth_oauthlib.flow import InstalledAppFlow
def authenticate_google_calendar() -> Credentials:
creds: Credentials = None
if os.path.exists("token.json"):
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
if not creds or not creds.valid:
flow = InstalledAppFlow.from_client_secrets_file(CREDENTIALS_FILE, SCOPES)
creds: Credentials = flow.run_local_server(port=0)
with open("token.json", "w") as token:
token.write(creds.to_json())
return creds
def analyze_eb1a_relevance(events: list[dict[str,str]]) -> list[tuple[int,str,str]]:
prioritized_events = []
for event in events:
title: str = event.get("summary", "Unknown Event")
description = event.get("description", "")
eb1a_score = 0
if any(keyword in title.lower() for keyword in ["conference", "summit", "keynote", "talk"]):
eb1a_score += 5
if any(keyword in title.lower() for keyword in ["panel", "webinar", "workshop", "roundtable"]):
eb1a_score += 3
if any(keyword in description.lower() for keyword in ["networking", "meetup", "happy hour"]):
eb1a_score += 2
if "call for speakers" in description.lower() or "apply to speak" in description.lower():
eb1a_score += 4
for word in ["tech", "ai", "machine learning", "finance",
"cybersecurity"]:
if word in description.lower():
eb1a_score += 2
prioritized_events.append((eb1a_score, title, event.get("start", {}).get("dateTime", "Unknown Date")))
return sorted(prioritized_events, key=lambda x: x[0], reverse=True)
def fetch_luma_events() -> list[str]:
creds = authenticate_google_calendar()
service = build("calendar", "v3", credentials=creds)
luma_calendar_id = LUMA_CALENDAR_ID
if not luma_calendar_id:
return []
now = datetime.datetime.utcnow().isoformat() + "Z"
events_result = service.events().list(
calendarId=luma_calendar_id,
timeMin=now,
maxResults=20,
singleEvents=True,
orderBy="startTime"
).execute()
events: list[str] = events_result.get("items", [])
return events
def list_all_calendars(service):
calendars = service.calendarList().list().execute()
for cal in calendars.get("items", []):
print(f"- {cal.get('summary')} (ID: {cal.get('id')})")
return calendars.get("items", [])
def main() -> None:
#creds = authenticate_google_calendar()
#service = build("calendar", "v3", credentials=creds)
#list_all_calendars(service)
luma_events = fetch_luma_events()
if not luma_events:
print("No upcoming Luma events found.")
return
prioritized_events = analyze_eb1a_relevance(luma_events)
for score, title, date in prioritized_events:
print(f"[{score}] {title} - {date}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment