Compare commits

...

8 commits
0.4.3 ... main

Author SHA1 Message Date
a56103d4c7
update repo link 2023-09-18 18:47:23 +02:00
79cc041251
0.4.5 release 2023-09-07 18:52:09 +02:00
c9262519c3
Remove debug entry 2023-09-07 18:51:41 +02:00
f1a8bbe571
0.4.4 release 2023-09-07 18:30:08 +02:00
32329647bc
Update deps 2023-09-07 18:29:09 +02:00
e4aa5864eb
Add missing months 2023-09-07 18:20:51 +02:00
e1fc4b7a51
Resolve E0308 ?? 2023-09-07 18:19:29 +02:00
e18b11a5fe
Don't crash when the class isn't bold 2023-04-23 01:35:00 +02:00
4 changed files with 499 additions and 649 deletions

1094
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,21 +1,21 @@
[package]
name = "cal8tor"
version = "0.4.3"
version = "0.4.5"
authors = ["Mylloon"]
edition = "2021"
description = "Extractor of the calendar of the IT degree of university Paris 8"
readme = "README.md"
repository = "https://git.kennel.ml/Anri/cal8tor"
repository = "https://git.mylloon.fr/Anri/cal8tor"
keywords = ["scrape", "calendar"]
publish = false
license = "AGPL-3.0-or-later"
[dependencies]
reqwest = { version = "0.11" }
tokio = { version = "1.27", features = ["full"] }
scraper = "0.16"
regex = "1.7.3"
chrono = "0.4.24"
tokio = { version = "1.32", features = ["full"] }
scraper = "0.17"
regex = "1.9"
chrono = "0.4.28"
ics = "0.5"
uuid = { version = "1.2.2", features = ["v4", "fast-rng"] }
clap = { version = "4.0.32", features = ["derive"] }
uuid = { version = "1.4", features = ["v4", "fast-rng"] }
clap = { version = "4.4", features = ["derive"] }

View file

@ -1,4 +1,4 @@
use chrono::{DateTime, TimeZone, Utc};
use chrono::{DateTime, Utc};
use regex::{Captures, Regex};
use scraper::{Html, Selector};
use std::collections::HashMap;
@ -77,9 +77,17 @@ async fn get_webpage(user_agent: &str) -> Result<Html, Box<dyn std::error::Error
fn anglophonization(date: &str) -> String {
let dico = HashMap::from([
("janvier", "january"),
("février", "february"),
("mars", "march"),
("avril", "april"),
("mai", "may"),
("juin", "june"),
("juillet", "july"),
("août", "august"),
("septembre", "september"),
("octobre", "october"),
("novembre", "november"),
("décembre", "december"),
]);
// New regex of all the french month
@ -90,13 +98,13 @@ fn anglophonization(date: &str) -> String {
.unwrap();
format!(
// Use 12:00 for chrono parser
"{} 12:00",
// Use 12:00 and UTC TZ for chrono parser
"{} 12:00 +0000",
// Replace french by english month
re.replace_all(date, |cap: &Captures| {
match &cap[0] {
re.replace_all(date, |cap: &Captures| match &cap[0] {
month if dico.contains_key(month) => dico.get(month).unwrap(),
month => panic!("Unknown month: {}", month),
month => {
panic!("Unknown month: {}", month)
}
})
)
@ -106,6 +114,7 @@ fn anglophonization(date: &str) -> String {
fn get_date(date: &str) -> DateTime<Utc> {
// Use and keep UTC time, we have the hour set to 12h and
// Paris 8 is in France so there is no problems
Utc.datetime_from_str(&anglophonization(date), "%e %B %Y %H:%M")
DateTime::parse_from_str(&anglophonization(date), "%e %B %Y %H:%M %z")
.unwrap()
.into()
}

View file

@ -85,14 +85,11 @@ pub async fn timetable(
}
None => None,
},
room: capitalize(
&mut course
.select(&sel_strong)
.next()
.unwrap()
.inner_html()
.replace("<br>", ""),
),
room: capitalize(&mut match course.select(&sel_strong).next() {
Some(el) => el.inner_html().replace("<br>", ""),
// Error in the site, silently passing... (the room is probably at the professor member)
None => String::new(),
}),
start: location_tracker,
size: match course.value().attr("colspan") {
Some(i) => i.parse().unwrap(),