feat: Atom feed

This commit is contained in:
2025-12-20 11:11:09 +01:00
parent c865fe9d97
commit 61bbc6acc5
5 changed files with 54 additions and 30 deletions
+2 -28
View File
@@ -1,29 +1,3 @@
use rss::{Channel, Guid, Item};
use std::error::Error;
pub mod discord;
pub async fn get_content(source: &str) -> Result<Channel, Box<dyn Error>> {
let content = reqwest::get(source)
.await?
.bytes()
.await?;
let channel = Channel::read_from(&content[..])?;
Ok(channel)
}
pub fn get_latest(rss: &Channel) -> Option<&Item> {
rss.items().first()
}
pub fn get_new<'a>(rss: &'a Channel, latest: &Guid) -> &'a [Item] {
match rss
.items()
.iter()
.position(|item| item.guid().map(|guid| guid == latest).unwrap_or(false))
.map(|i| &rss.items()[0..i])
{
None => rss.items(),
Some(list) => list,
}
}
pub mod rss;
pub mod atom;