Init repo
This commit is contained in:
38
src/main.rs
Normal file
38
src/main.rs
Normal 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(())
|
||||
}
|
Reference in New Issue
Block a user