[API/Edudziennik] Fix getting students on first login.

This commit is contained in:
Kacper Ziubryniewicz 2019-12-23 20:31:44 +01:00
parent e3741f1c75
commit 844d5b33bc
2 changed files with 8 additions and 5 deletions

View File

@ -85,8 +85,8 @@ object Regexes {
val EDUDZIENNIK_STUDENT_ID by lazy {
"""/Students/([\w-_]+?)/""".toRegex()
val EDUDZIENNIK_STUDENT_START_ID by lazy {
"""/Students/([\w-_]+?)/start""".toRegex()
}
val EDUDZIENNIK_SUBJECT_ID by lazy {
"""/Courses/([\w-_]+?)/""".toRegex()
@ -94,6 +94,9 @@ object Regexes {
val EDUDZIENNIK_TEACHER_ID by lazy {
"""/Teachers/([\w-_]+?)/""".toRegex()
}
val EDUDZIENNIK_GRADE_ID by lazy {
"""/Grades/([\w-_]+?)/""".toRegex()
}
val EDUDZIENNIK_SCHOOL_DETAIL_ID by lazy {
"""<a id="School_detail".*?/School/([\w-_]+?)/""".toRegex(RegexOption.DOT_MATCHES_ALL)

View File

@ -6,7 +6,7 @@ package pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.firstlogin
import org.greenrobot.eventbus.EventBus
import org.jsoup.Jsoup
import pl.szczodrzynski.edziennik.data.api.Regexes.EDUDZIENNIK_STUDENT_ID
import pl.szczodrzynski.edziennik.data.api.Regexes.EDUDZIENNIK_STUDENT_START_ID
import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.DataEdudziennik
import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.data.EdudziennikWeb
import pl.szczodrzynski.edziennik.data.api.edziennik.edudziennik.login.EdudziennikLoginWeb
@ -31,8 +31,8 @@ class EdudziennikFirstLogin(val data: DataEdudziennik, val onSuccess: () -> Unit
val doc = Jsoup.parse(text)
val accountName = doc.select("#user_dn").first().text().fixName()
doc.select("ul ul > li").first().children().forEach {
val studentId = EDUDZIENNIK_STUDENT_ID.find(it.attr("href"))?.get(1)
doc.select("ul ul").first().select("li > a").forEach {
val studentId = EDUDZIENNIK_STUDENT_START_ID.find(it.attr("href"))?.get(1)
if (studentId.isNullOrBlank()) return@forEach
val studentName = it.text().fixName()