library/calendar_sync.py aktualisiert
This commit is contained in:
@ -44,13 +44,22 @@ def connect_caldav(url, user=None, password=None, verify_ssl=True):
|
|||||||
password=password,
|
password=password,
|
||||||
ssl_verify_cert=verify_ssl
|
ssl_verify_cert=verify_ssl
|
||||||
)
|
)
|
||||||
target_path = urlparse(url).path
|
|
||||||
principal = client.principal()
|
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():
|
for calendar in principal.calendars():
|
||||||
if target_path in str(calendar.url):
|
if target_path in str(calendar.url):
|
||||||
return calendar
|
return calendar
|
||||||
|
|
||||||
raise Exception(f"Kalender mit Pfad '{target_path}' nicht gefunden")
|
raise Exception(f"Kalender mit Pfad '{target_path}' nicht gefunden")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"CalDAV-Fehler: {str(e)}")
|
raise Exception(f"CalDAV-Fehler: {str(e)}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user