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, user_agent: &str,
) -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> { ) -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> {
let semester = get_semester(semester_opt); let semester = get_semester(semester_opt);
let year = get_year(year_opt, semester); 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 .await
.expect("Can't reach info website."); .expect("Can't reach info website.");

View file

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