Web-based Calendar Aggregator https://ticker.c3d2.de/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
1.0 KiB

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!("Status: {}", res.status());
println!("Headers:\n{:?}", res.headers());
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.content.get("DTSTART").unwrap_or(&"?".to_owned()), obj.content.get("SUMMARY").unwrap_or(&"?".to_owned()));
println!("{}", obj.content.get("LOCATION").unwrap_or(&"?".to_owned()));
});
}
_ => 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");
}