2023-07-25 14:47:33 +01:00
|
|
|
use crate::prelude::*;
|
|
|
|
|
2024-01-23 08:06:28 +00:00
|
|
|
use crate::network::{NetUrl, NetworkEnv};
|
2023-07-29 20:36:03 +01:00
|
|
|
use atom_syndication::Feed;
|
2023-07-28 18:35:41 +01:00
|
|
|
|
2023-07-25 10:46:47 +01:00
|
|
|
mod find;
|
|
|
|
|
2023-07-25 14:47:33 +01:00
|
|
|
pub use find::find;
|
|
|
|
|
2024-01-23 08:06:28 +00:00
|
|
|
pub fn get(url: &NetUrl, e: &NetworkEnv) -> Result<Feed> {
|
2023-08-13 16:11:16 +01:00
|
|
|
let content = (e.fetch_as_bytes)(url).context(format!("Fetching feed: {}", url))?;
|
|
|
|
let channel = Feed::read_from(&content[..]).context("Could not parse RSS feed")?;
|
2023-07-29 20:36:03 +01:00
|
|
|
Ok(channel)
|
2023-07-28 18:35:41 +01:00
|
|
|
}
|
2024-01-23 08:06:28 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
|
|
pub struct ChannelName(pub String);
|
|
|
|
impl ChannelName {
|
|
|
|
pub fn from(channel_name: &str) -> Self {
|
|
|
|
Self(channel_name.to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl std::fmt::Display for ChannelName {
|
|
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
|
|
write!(f, "{}", self.0.as_str())
|
|
|
|
}
|
|
|
|
}
|