Compare commits
No commits in common. "main" and "0.4.3" have entirely different histories.
4 changed files with 649 additions and 499 deletions
1094
Cargo.lock
generated
1094
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
16
Cargo.toml
16
Cargo.toml
|
@ -1,21 +1,21 @@
|
|||
[package]
|
||||
name = "cal8tor"
|
||||
version = "0.4.5"
|
||||
version = "0.4.3"
|
||||
authors = ["Mylloon"]
|
||||
edition = "2021"
|
||||
description = "Extractor of the calendar of the IT degree of university Paris 8"
|
||||
readme = "README.md"
|
||||
repository = "https://git.mylloon.fr/Anri/cal8tor"
|
||||
repository = "https://git.kennel.ml/Anri/cal8tor"
|
||||
keywords = ["scrape", "calendar"]
|
||||
publish = false
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.11" }
|
||||
tokio = { version = "1.32", features = ["full"] }
|
||||
scraper = "0.17"
|
||||
regex = "1.9"
|
||||
chrono = "0.4.28"
|
||||
tokio = { version = "1.27", features = ["full"] }
|
||||
scraper = "0.16"
|
||||
regex = "1.7.3"
|
||||
chrono = "0.4.24"
|
||||
ics = "0.5"
|
||||
uuid = { version = "1.4", features = ["v4", "fast-rng"] }
|
||||
clap = { version = "4.4", features = ["derive"] }
|
||||
uuid = { version = "1.2.2", features = ["v4", "fast-rng"] }
|
||||
clap = { version = "4.0.32", features = ["derive"] }
|
||||
|
|
25
src/info.rs
25
src/info.rs
|
@ -1,4 +1,4 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use chrono::{DateTime, TimeZone, Utc};
|
||||
use regex::{Captures, Regex};
|
||||
use scraper::{Html, Selector};
|
||||
use std::collections::HashMap;
|
||||
|
@ -77,17 +77,9 @@ 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
|
||||
|
@ -98,13 +90,13 @@ fn anglophonization(date: &str) -> String {
|
|||
.unwrap();
|
||||
|
||||
format!(
|
||||
// Use 12:00 and UTC TZ for chrono parser
|
||||
"{} 12:00 +0000",
|
||||
// Use 12:00 for chrono parser
|
||||
"{} 12:00",
|
||||
// Replace french by english month
|
||||
re.replace_all(date, |cap: &Captures| match &cap[0] {
|
||||
month if dico.contains_key(month) => dico.get(month).unwrap(),
|
||||
month => {
|
||||
panic!("Unknown month: {}", month)
|
||||
re.replace_all(date, |cap: &Captures| {
|
||||
match &cap[0] {
|
||||
month if dico.contains_key(month) => dico.get(month).unwrap(),
|
||||
month => panic!("Unknown month: {}", month),
|
||||
}
|
||||
})
|
||||
)
|
||||
|
@ -114,7 +106,6 @@ 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
|
||||
DateTime::parse_from_str(&anglophonization(date), "%e %B %Y %H:%M %z")
|
||||
Utc.datetime_from_str(&anglophonization(date), "%e %B %Y %H:%M")
|
||||
.unwrap()
|
||||
.into()
|
||||
}
|
||||
|
|
|
@ -85,11 +85,14 @@ pub async fn timetable(
|
|||
}
|
||||
None => None,
|
||||
},
|
||||
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(),
|
||||
}),
|
||||
room: capitalize(
|
||||
&mut course
|
||||
.select(&sel_strong)
|
||||
.next()
|
||||
.unwrap()
|
||||
.inner_html()
|
||||
.replace("<br>", ""),
|
||||
),
|
||||
start: location_tracker,
|
||||
size: match course.value().attr("colspan") {
|
||||
Some(i) => i.parse().unwrap(),
|
||||
|
|
Reference in a new issue