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:
@ -68,6 +68,7 @@ class CacheController {
|
||||
val currentTime = System.currentTimeMillis() / 1000
|
||||
val timetableLink = "https://mosad.xyz"
|
||||
val weekNumberYear = 0
|
||||
val year = 0
|
||||
val instr = CacheController::class.java.getResourceAsStream("/html/Timetable_normal-week.html")
|
||||
|
||||
val timetableParser =
|
||||
@ -80,6 +81,7 @@ class CacheController {
|
||||
courseName,
|
||||
weekIndex,
|
||||
weekNumberYear,
|
||||
year,
|
||||
timetableLink
|
||||
), timetableTest ?: TimetableWeek()
|
||||
)
|
||||
@ -95,7 +97,7 @@ class CacheController {
|
||||
val currentTime = System.currentTimeMillis() / 1000
|
||||
|
||||
val timetableParser = TimetableParser(timetableLink)
|
||||
val weekNumberYear = timetableParser.parseWeekNumberYear()
|
||||
val calendarWeek = timetableParser.parseCalendarWeek()
|
||||
val timetable = timetableParser.parseTimeTable()
|
||||
|
||||
TimetableCourseWeek(
|
||||
@ -103,7 +105,8 @@ class CacheController {
|
||||
currentTime,
|
||||
courseName,
|
||||
weekIndex,
|
||||
weekNumberYear ?: 0,
|
||||
calendarWeek?.week ?: 0,
|
||||
calendarWeek?.year ?: 0,
|
||||
timetableLink
|
||||
), timetable ?: TimetableWeek()
|
||||
).also { if (timetable != null) timetableList[key] = it }
|
||||
@ -198,7 +201,7 @@ class CacheController {
|
||||
val timetableParser = TimetableParser(timetableCourse.value.meta.link)
|
||||
timetableCourse.value.timetable = timetableParser.parseTimeTable() ?: return@execute
|
||||
timetableCourse.value.meta.weekNumberYear =
|
||||
timetableParser.parseWeekNumberYear() ?: return@execute
|
||||
timetableParser.parseCalendarWeek()?.week ?: return@execute
|
||||
timetableCourse.value.meta.updateTime = System.currentTimeMillis() / 1000
|
||||
|
||||
saveTimetableToCache(timetableCourse.value) // save the updated timetable to the cache directory
|
||||
|
Reference in New Issue
Block a user