From 642387dcd3c6110f17ff451aaa84013400e2db97 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 23 Aug 2022 17:52:45 +0200 Subject: [PATCH] fix semester detection and rollback debug --- src/info.rs | 6 ++---- src/timetable.rs | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/info.rs b/src/info.rs index 24e1b7a..a944d87 100644 --- a/src/info.rs +++ b/src/info.rs @@ -59,7 +59,7 @@ pub async fn info() -> HashMap, i64)>> { /// Get info webpage async fn get_webpage() -> Result> { - /* let url = "https://informatique.up8.edu/licence-iv/edt"; + let url = "https://informatique.up8.edu/licence-iv/edt"; // We don't use reqwest::get() but a client with a custom user-agent // in order to avoid getting rate limit @@ -69,9 +69,7 @@ async fn get_webpage() -> Result> { let html = client.get(url).send().await?.text().await?; // Panic on error - crate::utils::check_errors(&html, url); */ - - let html = std::fs::read_to_string("target/debug-sch.htm").unwrap(); + crate::utils::check_errors(&html, url); Ok(Html::parse_document(&html)) } diff --git a/src/timetable.rs b/src/timetable.rs index 037fb24..bb29127 100644 --- a/src/timetable.rs +++ b/src/timetable.rs @@ -127,7 +127,7 @@ async fn get_webpage( semester: i8, letter: Option, ) -> Result> { - /* let url = { + let url = { let panic_semester_message = "Unknown semester."; let panic_letter_message = "Unknown letter."; @@ -172,8 +172,7 @@ async fn get_webpage( let html = reqwest::get(&url).await?.text().await?; // Panic on error - crate::utils::check_errors(&html, &url); */ - let html = std::fs::read_to_string("target/debug-l1a.htm").unwrap(); + crate::utils::check_errors(&html, &url); // Parse document let document = Html::parse_document(&html); @@ -306,7 +305,7 @@ fn get_semester(semester: Option, letter: Option) -> i8 { None => match letter { // Based on letter (kinda accurate) Some(c) => { - if c as i8 > 77 { + if c.to_ascii_uppercase() as i8 > 77 { // If letter is N or after 2 } else {