library/calendar_sync.py aktualisiert
This commit is contained in:
@ -20,7 +20,6 @@ def fetch_ics_events(url, user=None, password=None):
|
|||||||
raise Exception(f"ICS-Download fehlgeschlagen: {str(e)}")
|
raise Exception(f"ICS-Download fehlgeschlagen: {str(e)}")
|
||||||
|
|
||||||
def connect_caldav(url, user=None, password=None, verify_ssl=True):
|
def connect_caldav(url, user=None, password=None, verify_ssl=True):
|
||||||
"""Stellt Verbindung zum CalDAV-Kalender her"""
|
|
||||||
try:
|
try:
|
||||||
client = DAVClient(
|
client = DAVClient(
|
||||||
url,
|
url,
|
||||||
@ -28,15 +27,17 @@ 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
|
||||||
)
|
)
|
||||||
# Kalender-URL aus Pfad extrahieren
|
# Kalender-URL in String umwandeln
|
||||||
path = urlparse(url).path
|
target_path = urlparse(url).path
|
||||||
principal = client.principal()
|
principal = client.principal()
|
||||||
|
|
||||||
|
# Alle Kalender durchsuchen und URL als String vergleichen
|
||||||
for calendar in principal.calendars():
|
for calendar in principal.calendars():
|
||||||
if path in calendar.url:
|
if target_path in str(calendar.url): # WICHTIG: URL in String konvertieren
|
||||||
return calendar
|
return calendar
|
||||||
raise Exception("Kalender nicht gefunden")
|
raise Exception(f"Kalender mit Pfad '{target_path}' nicht gefunden")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception(f"CalDAV-Verbindungsfehler: {str(e)}")
|
raise Exception(f"CalDAV-Fehler: {str(e)}")
|
||||||
|
|
||||||
def sync_ics_to_caldav(module):
|
def sync_ics_to_caldav(module):
|
||||||
"""Haupt-Synchronisationslogik"""
|
"""Haupt-Synchronisationslogik"""
|
||||||
|
|||||||
Reference in New Issue
Block a user