TimetableParser: parse year
All checks were successful
continuous-integration/woodpecker the build was successful
All checks were successful
continuous-integration/woodpecker the build was successful
This also adds the parsed year to the meta object included in the timetable response
This commit is contained in:
@ -26,6 +26,7 @@ import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Semaphore
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import org.mosad.thecitadelofricks.CalendarWeek
|
||||
import org.mosad.thecitadelofricks.Lesson
|
||||
import org.mosad.thecitadelofricks.TimetableWeek
|
||||
import org.slf4j.LoggerFactory
|
||||
@ -131,11 +132,13 @@ class TimetableParser(timetableURL: String? = null, htmlDoc: Document? = null) {
|
||||
}
|
||||
|
||||
/**
|
||||
* parse the week number of the year for the timetable
|
||||
* parse the calendar week and the associated year for the timetable
|
||||
*/
|
||||
fun parseWeekNumberYear(): Int? = htmlDoc?.let {
|
||||
it.select("h1.timetable-caption").text().substringAfter("- ")
|
||||
.substringBefore(".").replace(" ", "").toInt()
|
||||
fun parseCalendarWeek(): CalendarWeek? = htmlDoc?.let {
|
||||
val dateStr = it.select("h1.timetable-caption").text().substringAfter("- ")
|
||||
val week = dateStr.substringBefore(".").replace(" ", "").toInt()
|
||||
val year = dateStr.substringAfter("Woche ").replace(" ", "").toInt()
|
||||
CalendarWeek(week, year)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
|
Reference in New Issue
Block a user