feat: auto-detect meeting URL from argument or clipboard

This commit is contained in:
Oliver Hofmann 2026-05-17 11:52:56 +02:00
parent 72aff02a9b
commit 01785d6ddc
2 changed files with 50 additions and 8 deletions

56
main.py
View File

@ -2,12 +2,15 @@
"""TeamPulse — Teams meeting chat audit tool.
Usage:
.venv/bin/python main.py
.venv/bin/python main.py [meeting-url]
Opens a browser, navigates to Teams Web. Post !start "Presenter Name" and
!stop in the meeting chat to define a time window. A Markdown memo is
saved to the current directory when the window closes.
If no URL is given, the clipboard is checked for a Teams meeting link.
If neither yields a URL, navigate manually in the browser window.
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 subprocess
import sys
from pathlib import Path
@ -22,16 +25,56 @@ from teampulse.monitor import Monitor
from teampulse.resolver import Resolver
CACHE_PATH = Path.home() / ".teampulse" / "cache.json"
TEAMS_URL = "https://teams.microsoft.com"
def _read_clipboard() -> str:
try:
system = platform.system()
if system == "Darwin":
return subprocess.check_output(["pbpaste"]).decode("utf-8").strip()
elif system == "Linux":
return subprocess.check_output(["xclip", "-selection", "clipboard", "-o"]).decode("utf-8").strip()
elif system == "Windows":
return subprocess.check_output(
["powershell", "-command", "Get-Clipboard"], text=True
).strip()
except Exception:
pass
return ""
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:
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
return None
def main():
meeting_url = _get_meeting_url()
with sync_playwright() as playwright:
print("Starte Browser...")
context = create_context(playwright, headless=False)
ensure_logged_in(context)
page = context.new_page()
page.goto("https://teams.microsoft.com")
if meeting_url:
page.goto(meeting_url)
else:
page.goto(TEAMS_URL)
print("\nKeine Meeting-URL gefunden — bitte im Browser zur Chat-Seite navigieren.")
print("Tipp: Meeting-Link aus Teams kopieren, dann Skript neu starten.\n")
monitor = Monitor(page=page, current_user="")
print("Lese eingeloggten Nutzer...")
@ -39,8 +82,7 @@ def main():
monitor._current_user = current_user
print(f"Eingeloggt als: {current_user}")
print("\nNavigiere im Browser zur Meeting-Chat-Seite.")
print("Poste dann '!start \"Name des Vortragenden\"' im Chat.\n")
print("\nPoste '!start \"Name des Vortragenden\"' im Chat um zu beginnen.\n")
window = monitor.run()

View File

@ -9,4 +9,4 @@ if [ ! -d ".venv" ]; then
.venv/bin/playwright install chromium
fi
.venv/bin/python main.py
.venv/bin/python main.py "$@"