mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-31 13:48:20 +01:00
[API/Edudziennik] Fix getting teacher in timetable and fix getting team name.
This commit is contained in:
parent
60ad2e81f3
commit
f165ee32e5
@ -133,6 +133,6 @@ object Regexes {
|
|||||||
"""<a id="Klass_detail".*?/Klass/([\w-_]+?)/""".toRegex(DOT_MATCHES_ALL)
|
"""<a id="Klass_detail".*?/Klass/([\w-_]+?)/""".toRegex(DOT_MATCHES_ALL)
|
||||||
}
|
}
|
||||||
val EDUDZIENNIK_CLASS_DETAIL_NAME by lazy {
|
val EDUDZIENNIK_CLASS_DETAIL_NAME by lazy {
|
||||||
"""<a id="Klass_detail".*?>Klasa (.*?)</a>""".toRegex(DOT_MATCHES_ALL)
|
"""<a id="Klass_detail".*?>(.*?)</a>""".toRegex(DOT_MATCHES_ALL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
|||||||
val course = lesson.select(".course").firstOrNull() ?: return@forEachIndexed
|
val course = lesson.select(".course").firstOrNull() ?: return@forEachIndexed
|
||||||
val info = course.select("span > span")
|
val info = course.select("span > span")
|
||||||
|
|
||||||
if (info.size < 2) return@forEachIndexed
|
if (info.isEmpty()) return@forEachIndexed
|
||||||
|
|
||||||
val type = when (course.hasClass("substitute")) {
|
val type = when (course.hasClass("substitute")) {
|
||||||
true -> Lesson.TYPE_CHANGE
|
true -> Lesson.TYPE_CHANGE
|
||||||
@ -99,11 +99,13 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
|||||||
|
|
||||||
/* Getting teacher */
|
/* Getting teacher */
|
||||||
|
|
||||||
val teacherElement = info[1].child(0)
|
val teacherId = if (info.size >= 2) {
|
||||||
val teacherName = teacherElement.text().trim()
|
val teacherElement = info[1].child(0)
|
||||||
val teacher = teacherName.splitName()?.let { (teacherLastName, teacherFirstName) ->
|
val teacherName = teacherElement.text().trim()
|
||||||
data.getTeacher(teacherFirstName, teacherLastName)
|
teacherName.splitName()?.let { (teacherLastName, teacherFirstName) ->
|
||||||
} ?: return@forEachIndexed
|
data.getTeacher(teacherFirstName, teacherLastName)
|
||||||
|
}?.id ?: -1
|
||||||
|
} else -1
|
||||||
|
|
||||||
val lessonObject = Lesson(profileId, -1).also {
|
val lessonObject = Lesson(profileId, -1).also {
|
||||||
it.type = type
|
it.type = type
|
||||||
@ -112,7 +114,7 @@ class EdudziennikWebTimetable(override val data: DataEdudziennik,
|
|||||||
it.startTime = startTime
|
it.startTime = startTime
|
||||||
it.endTime = endTime
|
it.endTime = endTime
|
||||||
it.subjectId = subject.id
|
it.subjectId = subject.id
|
||||||
it.teacherId = teacher.id
|
it.teacherId = teacherId
|
||||||
|
|
||||||
it.id = it.buildId()
|
it.id = it.buildId()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user