From 992b8a6dcf77f5a69a9eae4f7fabfe5d9aa349fc Mon Sep 17 00:00:00 2001 From: Aeddis Desauw Date: Tue, 7 May 2024 22:28:52 +0200 Subject: pull calendar script --- script/pull_calendar/pull_event.py | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 script/pull_calendar/pull_event.py (limited to 'script/pull_calendar/pull_event.py') diff --git a/script/pull_calendar/pull_event.py b/script/pull_calendar/pull_event.py new file mode 100644 index 0000000..51b04dc --- /dev/null +++ b/script/pull_calendar/pull_event.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +import vobject +import wget +import csv +from ics import Calendar, Event + +def get_month(month : int): + match month: + case 1: + return "Janvier" + case 2: + return "Fevrier" + case 3: + return "Mars" + case 4: + return "Avril" + case 5: + return "Mai" + case 6: + return "Juin" + case 7: + return "Juillet" + case 8: + return "Aout" + case 9: + return "Septembre" + case 10: + return "Octobre" + case 11: + return "Novembre" + case 12: + return "Decembre" + +if __name__ == "__main__": + url = "https://sogo.deuxfleurs.fr/SOGo/dav/public/lx/Calendar/22-63E29280-1-71341300.ics" + filename = wget.download(url) + + # read the data from the file + data = open(filename).read() + + c = Calendar(data) + for e in c.events: + html = "
  • " + + + if (e.location is not None and "http" in e.location): + html += " en ligne" + elif e.location is not None: + html += e.location + html += "," + + html += " le " + str(e.begin.day) + " " + get_month(e.begin.month) + " " + str(e.begin.year)+ " à " + + if e.begin.hour == 0: + html += "00:" + else: + html += str(e.begin.hour) + ":" + + if e.begin.minute == 0: + html += "00 " + else: + html += str(e.begin.minute) + "" + + if e.description is not None : + html += ".
    " + e.description + "
  • " + + print("\n" + html) -- cgit v1.2.3