summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-09-07 08:42:34 +0100
committerJoe Carstairs <me@joeac.net>2026-09-07 08:42:34 +0100
commit9559966f777dec3389bd85a8a285e19165d057de (patch)
treefaa431734ad7c04d37a41e329e5b7c0c02c1aa60
parent4b48bb90e3def4536fc4861290e90bb1720192ec (diff)
adds source to items
-rw-r--r--src/main.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 387f1c9..25a008d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,7 +7,7 @@ use std::{fs::File, future, io::{BufRead, BufReader}, path::{Path, PathBuf}};
use anyhow::anyhow;
use clap::Parser;
use futures::{StreamExt, executor::block_on};
-use rss::Channel;
+use rss::{Channel, Item, Source};
use crate::{channel::make_new_empty_channel, config::Config, retrieve::retrieve};
@@ -58,9 +58,19 @@ fn generate_channel(urls: Vec<String>, config: Config) -> Channel {
let mut channel = make_new_empty_channel(config);
block_on(async {
retrieve(urls.iter().map(AsRef::as_ref)).await.for_each(|c| {
- channel.items.append(&mut c.into_items());
+ channel.items.append(&mut items_with_source(c));
future::ready(())
}).await;
});
channel
}
+
+fn items_with_source(c: Channel) -> Vec<Item> {
+ let source = Source {
+ url: c.link.clone(),
+ title: Some(c.title.clone()),
+ };
+ c.into_items().into_iter()
+ .map(|mut item| { item.source = Some(source.clone()); item })
+ .collect()
+}