1
0
Fork 0
forked from Deuxfleurs/site

pull calendar script

This commit is contained in:
Aeddis Desauw 2024-05-07 22:28:52 +02:00
parent b3725ac2ac
commit 992b8a6dcf
3 changed files with 95 additions and 1 deletions

21
.gitignore vendored
View file

@ -2,3 +2,24 @@ public/
node_modules/
*.swp
.awsclirc
reated by https://www.toptal.com/developers/gitignore/api/venv
# Edit at https://www.toptal.com/developers/gitignore?templates=venv
### venv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
.Python
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
.venv
pip-selfcheck.json
# End of https://www.toptal.com/developers/gitignore/api/venv
script/calendar_generator/.gitignore

View file

@ -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 = "<li role=\"none\"><a href="
if (e.location is not None and "http" in e.location):
html += "\"" + e.location + "\""
else:
html += "\"#\""
html += ">"
html += e.name + "</a> "
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 += "<span class=\"highlight\"> 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 </span>"
else:
html += str(e.begin.minute) + "</span>"
if e.description is not None :
html += ".<br>" + e.description + "</li>"
print("\n" + html)

File diff suppressed because one or more lines are too long