From 656e3d2259e118045bc466dc046eadd13cf65758 Mon Sep 17 00:00:00 2001 From: midas Date: Thu, 4 Sep 2025 14:53:17 +0000 Subject: [PATCH] library/calendar_sync.py aktualisiert --- library/calendar_sync.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/calendar_sync.py b/library/calendar_sync.py index b84c596..efa6d8a 100644 --- a/library/calendar_sync.py +++ b/library/calendar_sync.py @@ -44,13 +44,22 @@ def connect_caldav(url, user=None, password=None, verify_ssl=True): password=password, ssl_verify_cert=verify_ssl ) - target_path = urlparse(url).path principal = client.principal() + target_path = urlparse(url).path + # 1. Direkt versuchen mit bekannter Kalender-URL + try: + return principal.calendar(url) + except Exception as direct_err: + logging.warning(f"Direkter Zugriff auf Kalender fehlgeschlagen: {direct_err}") + + # 2. Fallback: Durch alle bekannten Kalender iterieren for calendar in principal.calendars(): if target_path in str(calendar.url): return calendar + raise Exception(f"Kalender mit Pfad '{target_path}' nicht gefunden") + except Exception as e: raise Exception(f"CalDAV-Fehler: {str(e)}")