All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.wulkanowy.sdk.scrapper.homework.HomeworkMapper.kt Maven / Gradle / Ivy

Go to download

Unified way of retrieving data from the UONET+ register through mobile api and scraping api

There is a newer version: 2.7.0
Show newest version
package io.github.wulkanowy.sdk.scrapper.homework

import org.jsoup.parser.Parser
import java.time.LocalDate

internal fun List.mapHomework(startDate: LocalDate, endDate: LocalDate?): List {
    val end = endDate ?: startDate
    return asSequence().map { day ->
        day.items.map { homework ->
            val teacherAndCode = homework.teacher.split(", ").first().split(" [")
            val teacher = teacherAndCode.first()
            val teacherCode = teacherAndCode.last().removeSuffix("]")
            homework.copy(
                teacher = teacher,
                date = day.date,
                content = Parser.unescapeEntities(homework.content, true),
            ).apply {
                teacherSymbol = teacherCode
                _attachments = homework.attachments.map { it.url to it.filename }
            }
        }
    }.flatten().filter {
        it.date.toLocalDate() in startDate..end
    }.sortedWith(compareBy({ it.date }, { it.subject })).toList()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy