Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

kos-loader

ci-python Code style: black Imports: isort Checked with mypy linting: pylint

Data loader for CTU TimeTable Generator


This tool downloads data from the undocumented private KOS API using a using traditional KOS login details.

Usage

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.pem

Update the PUB_KEY_PEM variable in encrypt_cookie.js.

Get cookies from browser:

  1. Open kos.cvut.cz in browser
  2. Login
  3. Open developer console (F12)
  4. Open Application tab -> Cookies -> https://kos.cvut.cz
  5. Open Console
  6. Paste this code in console
  7. Run await encryptCookie('<YOUR_COOKIE_VALUE>') with copy-pasted cookie values for each cookie:
    • JSESSIONID
    • XSRF-TOKEN
    • BIGipServerFARM-IS-STUD-NEWKOS-HTTPS
    • msal.cache.encryption
  8. 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 

Process description

  1. Download list of all semesters
  2. Get current and the following semester
  3. Download list of all courses
  4. Download list of all paralles in the two selected semesters
  5. For each semester match parallels to the courses
  6. Filter out courses with no parallels for each semester
  7. Save these data

Data format

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
                            ]
                        },
                        // ...
                    ],
                },
                // ...
            ]
        }
        // ...
    ],
    // ...
}