You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

30 lines
982 B

from ics import Calendar
import requests, arrow, logging
# VARIABLES
log_file = "logfile"
url = "https://0783636d.index-education.net/pronote/ical/Agenda.ics?icalsecurise=3972E4CB6D2FF1DE199B75C1969DC54C867D1CA9A09B1C797A0342D5A2749FD9695E01FD2EE008B66074C8A9C38FB737&version=2021.0.2.3&param=66683d31266f3d31"
dates_file = "./dates.txt"
proxy = ""
logging.basicConfig(level=logging.INFO, filename=log_file, filemode="a+",format="%(asctime)-15s %(levelname)-8s %(message)s")
try:
c = Calendar(requests.get(url,proxies=proxy).text)
e = list(c.timeline)
except Exception:
logging.error("Erreur lors de l'accès au calendrier ! script annulé")
exit()
try:
f = open(dates_file, "w")
for x in e:
if x.name.casefold() == "lire ensemble":
print(x.begin, file=f)
print(x.end, file=f)
f.close()
logging.info("Fichier mis à jour le {}".format(arrow.utcnow().to('Europe/Paris').format('YYYY-MM-DD HH:mm')))
except IOError:
logging.error("Erreur de lecture/ecriture")