diff --git a/agenda/data.py b/agenda/data.py index 36f1ad4..566801c 100644 --- a/agenda/data.py +++ b/agenda/data.py @@ -24,6 +24,7 @@ from . import ( economist, fx, gwr, + meetup, stock_market, subscription, sun, @@ -259,6 +260,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]: events += read_events_yaml(my_data, last_year, next_year) events += subscription.get_events(os.path.join(my_data, "subscriptions.yaml")) events += economist.publication_dates(last_week, next_year) + events += meetup.get_events(my_data) events += domains.renewal_dates(my_data) diff --git a/agenda/meetup.py b/agenda/meetup.py new file mode 100644 index 0000000..3330e52 --- /dev/null +++ b/agenda/meetup.py @@ -0,0 +1,29 @@ +"""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