fix semester detection and rollback debug

This commit is contained in:
Mylloon 2022-08-23 17:52:45 +02:00
parent 0e714fd4d3
commit 642387dcd3
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 5 additions and 8 deletions

View file

@ -59,7 +59,7 @@ pub async fn info() -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> {
/// Get info webpage
async fn get_webpage() -> Result<Html, Box<dyn std::error::Error>> {
/* 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<Html, Box<dyn std::error::Error>> {
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))
}

View file

@ -127,7 +127,7 @@ async fn get_webpage(
semester: i8,
letter: Option<char>,
) -> Result<Html, Box<dyn std::error::Error>> {
/* 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<i8>, letter: Option<char>) -> 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 {