Init repo

This commit is contained in:
2024-11-29 20:51:17 +01:00
commit 3f0b99c5df
6 changed files with 1728 additions and 0 deletions

38
src/main.rs Normal file
View File

@@ -0,0 +1,38 @@
use anyhow::{
Context,
Result,
};
use rss::Channel;
fn fetch_feed() -> Result<Channel> {
let content = reqwest::blocking::get("https://feed.zugfunk-podcast.de/")?.bytes()?;
let channel = Channel::read_from(&content[..])?;
Ok(channel)
}
fn main() -> Result<()> {
let feed = fetch_feed()?;
let mut out = String::new();
out.push_str("<!DOCTYPE html>\n");
out.push_str("<html>\n");
out.push_str("<head>\n");
out.push_str("</head>\n");
out.push_str("<body>\n");
out.push_str("<ul>\n");
for item in feed.items {
out.push_str(&format!("<li><a href=\"{}\">{}</a></li>\n", item.link.context("No link found")?, item.title.context("No title found")?));
}
out.push_str("</ul>\n");
out.push_str("</body>\n");
out.push_str("</html>\n");
std::fs::write("index.html", out)?;
Ok(())
}