36 lines
1.0 KiB
Rust
36 lines
1.0 KiB
Rust
use std::io::Read;
|
|
|
|
mod ics;
|
|
use ics::Parser;
|
|
|
|
fn fetch(client: &reqwest::Client, url: &str) -> Result<(), Box<dyn std::error::Error>> {
|
|
let mut res = client.get(url).send()?;
|
|
|
|
println!("{} {}", res.status(), url);
|
|
|
|
let mut p = Parser::new();
|
|
let mut buf = [0; 8192];
|
|
loop {
|
|
match res.read(&mut buf)? {
|
|
len if len > 0 => {
|
|
let data = &buf[..len];
|
|
p.feed(data, |obj| {
|
|
println!("- [{}] {}", obj.get("DTSTART").unwrap_or("?"), obj.get("SUMMARY").unwrap_or("?"));
|
|
print!(" {}", obj.get("LOCATION").unwrap_or("?"));
|
|
obj.get("URL").map(|url| print!(" <{}>", url));
|
|
println!("");
|
|
});
|
|
}
|
|
_ => break,
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn main() {
|
|
let client = reqwest::Client::new();
|
|
fetch(&client, "https://c3d2.de/ical.ics").expect("fetch");
|
|
fetch(&client, "https://www.dresden-science-calendar.de/calendar/de/iCalSync.ics").expect("fetch");
|
|
}
|