From 3a993bc74199db3db533fbe6f3697c002b9c098f Mon Sep 17 00:00:00 2001 From: Oliver Hofmann Date: Sun, 17 May 2026 12:15:24 +0200 Subject: [PATCH] fix: extract Teams URL via regex to support 'Teilnahmeinfos kopieren' format --- main.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 951001a..990fd6d 100644 --- a/main.py +++ b/main.py @@ -10,10 +10,13 @@ Post !start "Presenter Name" and !stop in the chat to define a time window. A Markdown memo is saved to the current directory when the window closes. """ import platform +import re import subprocess import sys from pathlib import Path +_TEAMS_URL_RE = re.compile(r'https://teams(?:\.live)?\.microsoft\.com/\S+') + sys.path.insert(0, str(Path(__file__).parent / "src")) from playwright.sync_api import sync_playwright @@ -44,17 +47,23 @@ def _read_clipboard() -> str: return "" +def _extract_teams_url(text: str) -> str | None: + m = _TEAMS_URL_RE.search(text) + return m.group(0) if m else None + + def _get_meeting_url() -> str | None: if len(sys.argv) > 1: - url = sys.argv[1].strip() - if "teams.microsoft.com" in url or "teams.live.com" in url: + url = _extract_teams_url(sys.argv[1]) + if url: print(f"Meeting-URL aus Argument: {url[:60]}...") return url clip = _read_clipboard() - if "teams.microsoft.com" in clip or "teams.live.com" in clip: - print(f"Meeting-URL aus Clipboard: {clip[:60]}...") - return clip + url = _extract_teams_url(clip) + if url: + print(f"Meeting-URL aus Clipboard: {url[:60]}...") + return url return None