Support atom feeds too

This commit is contained in:
2024-11-29 21:20:46 +01:00
parent 3f0b99c5df
commit 62da50567e
3 changed files with 144 additions and 127 deletions

View File

@@ -2,12 +2,14 @@ use anyhow::{
Context,
Result,
};
use rss::Channel;
use feed_rs::{
parser::parse,
model::Feed,
};
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 fetch_feed() -> Result<Feed> {
let content = reqwest::blocking::get("https://www.youtube.com/feeds/videos.xml?channel_id=UC0intLFzLaudFG-xAvUEO-A")?.bytes()?;
Ok(parse(&content[..])?)
}
fn main() -> Result<()> {
@@ -23,8 +25,8 @@ fn main() -> Result<()> {
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")?));
for item in feed.entries {
out.push_str(&format!("<li><a href=\"{}\">{}</a></li>\n", item.links.first().context("No link found")?.href, item.title.context("No title found")?.content));
}
out.push_str("</ul>\n");