forked from Anri/cal8tor
fix semester detection and rollback debug
This commit is contained in:
parent
0e714fd4d3
commit
642387dcd3
2 changed files with 5 additions and 8 deletions
|
@ -59,7 +59,7 @@ pub async fn info() -> HashMap<usize, Vec<(DateTime<Utc>, i64)>> {
|
||||||
|
|
||||||
/// Get info webpage
|
/// Get info webpage
|
||||||
async fn get_webpage() -> Result<Html, Box<dyn std::error::Error>> {
|
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
|
// We don't use reqwest::get() but a client with a custom user-agent
|
||||||
// in order to avoid getting rate limit
|
// 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?;
|
let html = client.get(url).send().await?.text().await?;
|
||||||
|
|
||||||
// Panic on error
|
// Panic on error
|
||||||
crate::utils::check_errors(&html, url); */
|
crate::utils::check_errors(&html, url);
|
||||||
|
|
||||||
let html = std::fs::read_to_string("target/debug-sch.htm").unwrap();
|
|
||||||
|
|
||||||
Ok(Html::parse_document(&html))
|
Ok(Html::parse_document(&html))
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ async fn get_webpage(
|
||||||
semester: i8,
|
semester: i8,
|
||||||
letter: Option<char>,
|
letter: Option<char>,
|
||||||
) -> Result<Html, Box<dyn std::error::Error>> {
|
) -> Result<Html, Box<dyn std::error::Error>> {
|
||||||
/* let url = {
|
let url = {
|
||||||
let panic_semester_message = "Unknown semester.";
|
let panic_semester_message = "Unknown semester.";
|
||||||
let panic_letter_message = "Unknown letter.";
|
let panic_letter_message = "Unknown letter.";
|
||||||
|
|
||||||
|
@ -172,8 +172,7 @@ async fn get_webpage(
|
||||||
let html = reqwest::get(&url).await?.text().await?;
|
let html = reqwest::get(&url).await?.text().await?;
|
||||||
|
|
||||||
// Panic on error
|
// Panic on error
|
||||||
crate::utils::check_errors(&html, &url); */
|
crate::utils::check_errors(&html, &url);
|
||||||
let html = std::fs::read_to_string("target/debug-l1a.htm").unwrap();
|
|
||||||
|
|
||||||
// Parse document
|
// Parse document
|
||||||
let document = Html::parse_document(&html);
|
let document = Html::parse_document(&html);
|
||||||
|
@ -306,7 +305,7 @@ fn get_semester(semester: Option<i8>, letter: Option<char>) -> i8 {
|
||||||
None => match letter {
|
None => match letter {
|
||||||
// Based on letter (kinda accurate)
|
// Based on letter (kinda accurate)
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
if c as i8 > 77 {
|
if c.to_ascii_uppercase() as i8 > 77 {
|
||||||
// If letter is N or after
|
// If letter is N or after
|
||||||
2
|
2
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue