This script permit anyone studing at Scholanova, to retrieve the timetable (emploi du temps) and convert it in iCalendar format for importing it in her agenda.
This script makes a first request for retrieving the AJAX token (because the payload send a string explaining the error with the AJAX token 🤷). After that, it make a new request with the AJAX token, parse the XML payload (yep it's a XML payload inside a JSON payload...), create a calendar by inserting all created events (or all events up to the specified limit) and create a ics file. If a messaging service (example: Discord) and a webhook URL was sent in parameters, it send a message with the ics file in attachment.
- Retrieves the timetable and store it in a ics file.
- Can limit the number of days retrieved by the script
- Can notify on a messaging service and sending the ics file in attachment.
The script is compatible with theses messaging services:
- Discord
- Python >= 3.5
- Poetry (highly recommended) or pip (as fallback)
- Cron or similar
- Timetable url (for security reasons, it's not hardcoded for not exposing the url because anyone can access to it without authentication)
Note: This script can be runned on Function as a Service (FaaS) platforms. It compatible with AWS Lambda, Azure Function and GCloud Function.
First of all, clone this repo and use the latest tag created:
git clone https://github.com/themimitoof/sn-edt2ics.git
cd sn-edt2ics
git checkout v0.1.0
Create a virtualenv by using:
python -m venv venv
source venv/bin/activate
Now, you need to install dependencies. If you have poetry installed, you can use poetry install
. If isn't, you can use pip by using the command pip install -r requirements.txt
.
....
python edt2ics.py \
--url <url> \
--class_id <integer> \
--notifier discord \
--notifier_url https://discordapp.com/api/webhooks/<id>/<token>
Finally, you can configure cron task to run the script periodically. For this, run the command crontab -e
and add your configuration. For example, for running the script each fridays at 0h00:
0 0 * * 5 python /opt/sn-edt2ics/ python edt2ics.py --url <url> --class_id <integer> --notifier discord --notifier_url https://discordapp.com/api/webhooks/<id>/<token> >> /tmp/log/sn-edt2ics.log
...
...
...
You can create a Pull request for sending your contributions or create an issue for reporting a bug or adding a messaging provider.
Note: This project use black and is conform as max as possible to the PEP8.
This script is shipped with MIT license.