Fix some bugs

This commit is contained in:
Mylloon 2023-09-28 00:23:51 +02:00
parent dc3a5c6d8e
commit 5fc7d9209c
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 9 additions and 7 deletions

View file

@ -12,10 +12,10 @@ pub async fn info(
user_agent: &str,
) -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> {
let semester = get_semester(semester_opt);
let year = get_year(year_opt, semester);
let document = get_webpage(level, semester, &year, user_agent)
// Fetch the timetable of the FIRST semester
let document = get_webpage(level, 1, &year, user_agent)
.await
.expect("Can't reach info website.");

View file

@ -89,11 +89,13 @@ pub async fn timetable(
.name("name")
.unwrap()
.as_str().to_owned(),
professor: match i.select(&sel_small).last().unwrap().inner_html() {
i if i.starts_with("<span") => None,
i => Some(i),
},
room: Regex::new(r"(<table.*<\/table>|<br>.*?<br>.*?)<br>(?P<location>.*?)<br>")
professor: if let Some(raw_prof) = i.select(&sel_small).last() {
match raw_prof.inner_html() {
i if i.starts_with("<span") => None,
i => Some(i),
}
} else { None },
room: Regex::new(r"(<table.*<\/table>|<br>.*?<br>.*?)?<br>(?P<location>.*?)<br>")
.unwrap()
.captures(&binding)
.unwrap().name("location")