agenda/agenda/meetup.py
2024-01-16 15:32:39 +00:00

30 lines
806 B
Python

"""Meetup.com events I'm attending."""
import json
import os.path
from datetime import datetime
from .types import Event
def get_events(data_dir: str) -> list[Event]:
"""Get events."""
data = json.load(open(os.path.join(data_dir, "meetup_upcoming.json")))["data"]
events: list[Event] = []
item_list = data["self"]["upcomingEvents"]["edges"]
for item in item_list:
item_event = item["node"]["event"]
start = datetime.fromisoformat(item["node"]["event"]["dateTime"])
end = datetime.fromisoformat(item["node"]["event"]["endTime"])
e = Event(
date=start,
end_date=end,
name="meetup",
title=item_event["title"],
url=item_event["eventUrl"],
)
events.append(e)
return events