Data loader for CTU TimeTable Generator
This tool downloads data from the undocumented private KOS API using a using traditional KOS login details.
Generate public and private keys.
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private_key.pem
openssl rsa -in private_key.pem -pubout -out public_key.pemUpdate the PUB_KEY_PEM variable in encrypt_cookie.js.
Get cookies from browser:
- Open kos.cvut.cz in browser
- Login
- Open developer console (F12)
- Open Application tab -> Cookies -> https://kos.cvut.cz
- Open Console
- Paste this code in console
- Run
await encryptCookie('<YOUR_COOKIE_VALUE>')with copy-pasted cookie values for each cookie:JSESSIONIDXSRF-TOKENBIGipServerFARM-IS-STUD-NEWKOS-HTTPSmsal.cache.encryption
- Copy the output values and use them as encrypted cookies in kos-loader
export COOKIES_PRIVATE_KEY=private key in PEM format
export JSESSIONID_ENC=encrypted and base64 encoded cookie value
export XSRF_TOKEN_ENC=...
export BIGIPSERVERFARM_IS_STUD_NEWKOS_HTTPS_ENC=...
export MSAL_CACHE_ENCRYPTION_ENC=...
export LOGLEVEL=info
python3 -m kos_loader.kos_loader - Download list of all semesters
- Get current and the following semester
- Download list of all courses
- Download list of all paralles in the two selected semesters
- For each semester match parallels to the courses
- Filter out courses with no parallels for each semester
- Save these data
Example:
{
// Code of a semester
"B231": [
{
// Course code, should be unique among all courses
"code": "BI-QAP",
// Name of the class in Czech, or English if Czech is not available, or null
"name": "Kvantové algoritmy a programování",
"parallels": [
{
// Parallel number, should not be null and should be uniqe for a course, but I can't promise anything
"num": 101,
// P = Lecture, C = Tutorial, L = Lab
"type": "C",
// Parallel capacity or null
"capacity": 32,
// Number of spots already taken
"occupied_places": 18,
// Is this class full?
"is_full": false,
// Is it possible to join this parallel?
"can_register": true,
// List of all events of a given parallel, this shouldn't be empty
"timetable": [
{
// Days indexed from 1 -> 4 = Thursday
"day": 4,
// L, S or null for odd, even and both types of weeks classes
"week": "L",
// Room code, this should correctly indentify a room, or null
"room": "TH:A-s135",
// Time in the [HH, mm] format
"end": [
13,
30
],
// Time in the [HH, mm] format
"start": [
11,
0
]
},
// ...
],
},
// ...
]
}
// ...
],
// ...
}