library/calendar_sync.py aktualisiert

This commit is contained in:
2025-04-30 09:54:08 +00:00
parent 3c18f55d24
commit e029a341db

View File

@ -20,7 +20,6 @@ def fetch_ics_events(url, user=None, password=None):
raise Exception(f"ICS-Download fehlgeschlagen: {str(e)}")
def connect_caldav(url, user=None, password=None, verify_ssl=True):
"""Stellt Verbindung zum CalDAV-Kalender her"""
try:
client = DAVClient(
url,
@ -28,15 +27,17 @@ def connect_caldav(url, user=None, password=None, verify_ssl=True):
password=password,
ssl_verify_cert=verify_ssl
)
# Kalender-URL aus Pfad extrahieren
path = urlparse(url).path
# Kalender-URL in String umwandeln
target_path = urlparse(url).path
principal = client.principal()
# Alle Kalender durchsuchen und URL als String vergleichen
for calendar in principal.calendars():
if path in calendar.url:
if target_path in str(calendar.url): # WICHTIG: URL in String konvertieren
return calendar
raise Exception("Kalender nicht gefunden")
raise Exception(f"Kalender mit Pfad '{target_path}' nicht gefunden")
except Exception as e:
raise Exception(f"CalDAV-Verbindungsfehler: {str(e)}")
raise Exception(f"CalDAV-Fehler: {str(e)}")
def sync_ics_to_caldav(module):
"""Haupt-Synchronisationslogik"""