diff --git a/events_feeds.yml b/events_feeds.yml index a1ae172e..3fb89552 100644 --- a/events_feeds.yml +++ b/events_feeds.yml @@ -11,12 +11,12 @@ - name: PyWorking Sessions site_url: https://pyworking.cz/ url: https://www.meetup.com/pyworking/events/ - format: json-dl + format: meetupcom - name: PyData Prague site_url: https://www.meetup.com/pydata-prague/ url: https://www.meetup.com/pydata-prague/events/ - format: json-dl + format: meetupcom - name: Czech Python Events site_url: https://calendar.google.com/calendar/embed?src=kfdeelic1a13jsp7jvai861vfs%40group.calendar.google.com&ctz=Europe%2FPrague diff --git a/hooks/events.py b/hooks/events.py index 0aca20ab..eadd1d9f 100644 --- a/hooks/events.py +++ b/hooks/events.py @@ -55,11 +55,11 @@ def fetch_events(days_limit: int | None = None, past: bool = False) -> list[dict for event_data in parse_icalendar(feed["data"]) ] ) - elif feed["format"] == "json-dl": + elif feed["format"] == "meetupcom": events.extend( [ dict(feed=feed, **event_data) - for event_data in parse_json_dl(feed["data"], feed["url"]) + for event_data in parse_meetupcom(feed["data"], feed["url"]) ] ) else: @@ -115,22 +115,22 @@ def parse_icalendar(text: str) -> list[dict]: starts_at=to_prague_tz(event.begin), ends_at=to_prague_tz(event.end) if event.end else None, location=event.location, - url=event.url if event.url else find_first_url(event.description), + url=event.url if event.url else find_first_url(event.description or ""), is_tentative="tentative-date" in event.categories, ) for event in ics.Calendar(text).events ] -def parse_json_dl(html: str, base_url: str) -> list[dict]: +def parse_meetupcom(html: str, base_url: str) -> list[dict]: response = requests.get(base_url) - events = teemup.parse(response.text) + events: list[teemup.Event] = teemup.parse(response.text) return [ dict( name=event["title"], starts_at=event["starts_at"], ends_at=event["ends_at"], - location=event["venue"], + location=parse_meetupcom_venue(event["venue"]) if event["venue"] else None, url=event["url"], is_tentative=False, ) @@ -138,8 +138,18 @@ def parse_json_dl(html: str, base_url: str) -> list[dict]: ] -def parse_json_dl_location(location: dict[str, str]) -> str: - return f"{location['name']}, {location['address']['streetAddress']}, {location['address']['addressLocality']}, {location['address']['addressCountry']}" +def parse_meetupcom_venue(location: teemup.Venue) -> str: + return ", ".join( + filter( + None, + [ + location["name"], + location["address"], + location["city"], + location["country"], + ], + ) + ) def to_prague_tz(dt: datetime) -> datetime: diff --git a/poetry.lock b/poetry.lock index e52defcb..ca8d9c9b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "attrs" @@ -1034,13 +1034,13 @@ python-dateutil = ">=2.6.0" [[package]] name = "teemup" -version = "1.1.0" +version = "1.1.1" description = "If Meetup didn't become a walled garden, the world wouldn't need Teemup" optional = false python-versions = "<4.0,>=3.11" files = [ - {file = "teemup-1.1.0-py3-none-any.whl", hash = "sha256:b04c2bf6744d3e4ab04e06f709785de86cfa907cb3def2713995de776a0c5fd9"}, - {file = "teemup-1.1.0.tar.gz", hash = "sha256:dcd8b2986ac8121adab2d0d0012249bb13bf1cfa6a28a0a5b40f2496cd8ca059"}, + {file = "teemup-1.1.1-py3-none-any.whl", hash = "sha256:26115100c0723a487952d2bf711532b2871d723968215d16b3cdd3f69bad8ba5"}, + {file = "teemup-1.1.1.tar.gz", hash = "sha256:f00d466382eff644e1f1f2e009fc3b2e461e1268bd616a653b30e879ebd4218c"}, ] [package.dependencies] @@ -1109,4 +1109,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "a099ea2d6104135a526fcdba24792533c3e1ea4ed55d258f11cf6fed245e49e1" +content-hash = "f723c2d31918c1f140e80ebaa6f3b23d75881c41561f325553f55ae62464e89c" diff --git a/pyproject.toml b/pyproject.toml index b15bbbec..f9ae67d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,8 +13,8 @@ mkdocs-material = "9.5.39" strictyaml = "1.7.3" ics = {version = "0.8.0.dev0", allow-prereleases = true} requests = "2.32.3" -teemup = "1.1.0" mkdocs = "1.6.1" +teemup = "1.1.1" [tool.poetry.group.dev.dependencies] pytest = "8.3.2"